I am using a SparkJava (basically Jetty) web server behind an nginx proxy with ObjectBox.
I'm starting to notice a lot of
Hint: use closeThreadResources() to avoid finalizing recycled transactions (initial commit count: 213).
Hint: use closeThreadResources() to avoid finalizing recycled transactions (initial commit count: 213).
Hint: use closeThreadResources() to avoid finalizing recycled transactions (initial commit count: 213).
Hint: use closeThreadResources() to avoid finalizing recycled transactions (initial commit count: 213).
Hint: use closeThreadResources() to avoid finalizing recycled transactions (initial commit count: 213).
Hint: use closeThreadResources() to avoid finalizing recycled transactions (initial commit count: 213).
038-22:43:52.3260 [WARN ] Skipping low-level close for read-only cursor (non-creator thread 'java')
038-22:43:52.5815 [WARN ] Skipping low-level close for read-only cursor (non-creator thread 'java')
038-22:43:52.5815 [WARN ] Skipping low-level close for read-only cursor (non-creator thread 'java')
038-22:43:52.5815 [WARN ] Destroyed recycled transaction from non-owner thread 'java'
038-22:43:52.5820 [WARN ] Skipping low-level close for read-only cursor (non-creator thread 'java')
038-22:43:52.5820 [WARN ] Destroyed recycled transaction from non-owner thread 'java'
038-22:43:52.5821 [WARN ] Skipping low-level close for read-only cursor (non-creator thread 'java')
warnings, in my logs, and I'm thinking of ways around this.
What I've seen suggested, is possibly to call closeThreadResources() as suggested in the hints, possibly after each call has finished. However, I'm no expert on Jetty and not sure if each thread is killed or reused possibly. Maybe calling closeThreadResources() might break if threads are reused? Plus, I have multiple ObjectBox boxes, so I'd probably have to either remember which boxes have been used, or call closeThreadResources() on all of them. Not perfect, but doable.
Then there is also the possible reuse of queries, that might fix things, after reading https://github.com/objectbox/objectbox-java/issues/753#issuecomment-525314808. I can potentially redo most of my code to create the queries once, then set the parameter values when they're used. How thread safe is this, when being used by a webserver? i.e. if i change the value of a query to use it, and it's already being used by another thread, what happens?