-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session cache is cleared to often #839
Comments
This is something we are not gonna role back. It has to much potential to lead to inconsistent data: https://jira.spring.io/browse/DATAGRAPH-1249. I would rather introduce an additional overload for Would that work for you? |
The call is not directly via OGM. I have a SDN respository with a I understand that you need to clear the cache and totally agree that it otherwise can lead to inconsistent data. Is it an option to check the transaction mode and clear the cache if it is a read-write transaction and keep it if its a read-only transaction? |
I see. No, in that specific use case (custom query for known entity classes) there's no propagation. |
About how many custom queries are we talking? Would you be able to add a hint to them? I'm thinking about something like this I would rather not change the current SDN code to do this on some kind of heuristics. The code path that is taken when you ask with. I'll post a PR with the above functionality for you to try out. Looking forward to some feedback. |
Allow custom queries to indicate with `/*+ OGM READ_ONLY */` that they are read only. This will allow procedure calls to not flush the session and fix #839.
I have to check it, I found 80 call statements but some of them are write-statements. For sure, it is possible to add a hint to them. I will try out your changes and provide a feedback. My first thought was "looks like xml processing instructions in the 'good' old days" ;-) |
Hehe… :) I was like "wow, now I'm adding query hints like I used to with Oracle." |
Ok, lets go on with the "like Oracle" approach ;-) It works for me! I noticed that in line 127 there is also a Also I tried to integrate the new check in the existing regular expression. After some test with a colleague of mine we found a solution and I verified it with a JUnit 5 (with assertj) test:
|
Thank you people so much! I really like that approach (actually much better than mine) and I would incorporate it before our next release. |
Yes, we already hosted the JUG Paderborn Meetup last year when @meistermeier jumps in because of your travel problem. Maybe we can host another one when it is possible again, maybe we can talk to each other in October after my vacation. Looking forward for the next release and thank you for your great work! Without Neo4j OGM and SDN our work would not be possible or much more complicated. |
Thanks for your kind words. I have added your tests now + some multi line queries. I cannot get a regex ready to cater for those, but I moved the check for the hint into the method itself, very valid suggestions. Thanks! |
Allow custom queries to indicate with `/*+ OGM READ_ONLY */` that they are read only. This will allow procedure calls to not flush the session and fix #839.
Allow custom queries to indicate with `/*+ OGM READ_ONLY */` that they are read only. This will allow procedure calls to not flush the session and fix #839.
Allow custom queries to indicate with `/*+ OGM READ_ONLY */` that they are read only. This will allow procedure calls to not flush the session and fix #839.
In OGM Release 3.2.15 there was a change that the session cache is cleared when a potential write query is executed (
ExecuteQueryDelegates#query
line 125). I use stored procedures to read data from neo4j and now the session cache is cleared after each call of the stored procedure. Which can lead to performance degeneration.Expected Behavior
Clear the session cache only if necessary. Maybe it is possible to get the statistics back from the database as in the Neo4j Browser and use this information to decide wheter the cache must be cleared or not.
![image](https://user-images.githubusercontent.com/19815499/92689240-f8728c80-f33e-11ea-9afc-728d8a73e0d2.png)
Current Behavior
Cache is cleared on every call of a stored procedure, even if it a stored procedure that only reads data.
Context
As I use stored procedures to read data from neo4j the session cache is now more or less useless for me because it is cleared to often.
Your Environment
Steps to Reproduce
The text was updated successfully, but these errors were encountered: