-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Memory leak on backup restore with xquery triggers #5459
Comments
@line-o Could we get an update please? |
@adamretter Are you waiting for the screenshots? They are the same ones as in the other issue. I was expecting your PR, you were so eager to publish. |
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 8, 2024
XQuery trigger not found is acceptable behaviour (logs a debug message only, could get very chatty logs otherwise). BUT the exit path from the exception fails to tidy up the per-thread trigger state. This has been observed to leak memory; the per-thread doesn’t get cleaned up until the thread is deleted, and the trigger cyclic-check stack just builds up. So we clean up the trigger state when a trigger is not found. Closes eXist-db#5459
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 8, 2024
We may leak trigger states to thread local which can potentially occur when the specified XQueryTrigger library module is not available in the database Closes eXist-db#5459
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 8, 2024
XQuery trigger not found is acceptable behaviour (logs a debug message only, could get very chatty logs otherwise). BUT the exit path from the exception fails to tidy up the per-thread trigger state. This has been observed to leak memory; the per-thread doesn’t get cleaned up until the thread is deleted, and the trigger cyclic-check stack just builds up. So we clean up the trigger state when a trigger is not found. Closes eXist-db#5459
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 8, 2024
We may leak trigger states to thread local which can potentially occur when the specified XQueryTrigger library module is not available in the database Closes eXist-db#5459
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 8, 2024
XQuery trigger not found is acceptable behaviour (logs a debug message only, could get very chatty logs otherwise). BUT the exit path from the exception fails to tidy up the per-thread trigger state. This has been observed to leak memory; the per-thread doesn’t get cleaned up until the thread is deleted, and the trigger cyclic-check stack just builds up. So we clean up the trigger state when a trigger is not found. Closes eXist-db#5459
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 8, 2024
We may leak trigger states to thread local which can potentially occur when the specified XQueryTrigger library module is not available in the database Closes eXist-db#5459
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 8, 2024
We may leak trigger states to thread local which can potentially occur when the specified XQueryTrigger library module is not available in the database Closes eXist-db#5459
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 10, 2024
XQuery trigger not found is acceptable behaviour (logs a debug message only, could get very chatty logs otherwise). BUT the exit path from the exception fails to tidy up the per-thread trigger state. This has been observed to leak memory; the per-thread doesn’t get cleaned up until the thread is deleted, and the trigger cyclic-check stack just builds up. So we clean up the trigger state when a trigger is not found. Closes eXist-db#5459
adamretter
pushed a commit
to evolvedbinary/exist
that referenced
this issue
Oct 10, 2024
We may leak trigger states to thread local which can potentially occur when the specified XQueryTrigger library module is not available in the database Closes eXist-db#5459
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
I was able to reproduce the memory leak using the original dataset provided by @dariok. With enough resources, about 10 GB of RAM, the process did finish successfully. After restoring the entire dataset of 35 GB, containing 26874 XML files (including .html, .xsl, .svg), almost 5 GB of RAM retained.
There is ~59000 instances of
TriggerStatePerThread$TriggerState
. Since I can see that there is two instances for each restored item that is ~29500CREATE_DOCUMENT
triggers - one forBEFORE
and for theAFTER
phase.I was then wondering whether I was missing +3000 documents until I discovered that
CREATE_COLLECTION
was also invoked:With the
collection.xconf
as it is in the issue description (without any triggers configured) the outcome was very different. RAM usage stayed within reasonable bounds (<2 GB) and all memory was freed afterwards (see screenshot).My analysis indicates that TriggerStates are held in memory indefinitely and are the cause of the leak. This is especially interesting as the events that were triggered are not the ones that are defined and thus one would not expect them to be fired at all.
References
refs #4890
refs #5295
Expected behavior
XQueryTriggerStates to be removed from memory once the trigger is done.
To Reproduce
If the above isn't working, please tell us the exact steps you took when you encountered the problem:
full-backup-restore-with-triggers.zip
Screenshots
see above
Context
Additional context
conf.xml
? noneThe text was updated successfully, but these errors were encountered: