【发布时间】:2021-03-17 00:50:26
【问题描述】:
我在带有 ObjectBox 的 nginx 代理后面使用 SparkJava(基本上是 Jetty)Web 服务器。
我开始注意到很多
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')
警告,在我的日志中,我正在考虑解决这个问题的方法。
我看到的建议可能是按照提示中的建议拨打closeThreadResources(),可能在每次通话结束后。但是,我不是 Jetty 方面的专家,并且不确定每个线程是否可能被杀死或重用。如果线程被重用,也许调用closeThreadResources() 可能会中断?另外,我有多个 ObjectBox 框,所以我可能必须记住使用了哪些框,或者在所有这些框上调用 closeThreadResources()。不完美,但可行。
在阅读https://github.com/objectbox/objectbox-java/issues/753#issuecomment-525314808 之后,还有可能重用查询,这可能会解决问题。我可以重做大部分代码来创建一次查询,然后在使用它们时设置参数值。当被网络服务器使用时,这有多线程安全?即,如果我更改查询的值以使用它,并且它已经被另一个线程使用,会发生什么?
【问题讨论】:
标签: embedded-jetty spark-java objectbox