Skip to content
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

Cursor RxCachedThreadSchedules Storage error code -30790 #753

Closed
guqh opened this issue Aug 27, 2019 · 26 comments
Closed

Cursor RxCachedThreadSchedules Storage error code -30790 #753

guqh opened this issue Aug 27, 2019 · 26 comments

Comments

@guqh
Copy link

guqh commented Aug 27, 2019

image

不知道是 Cursor 导致 rxThread 无法释放还是RxThread 导致 Cursor 无法释放,一直持续增长

@guqh
Copy link
Author

guqh commented Aug 27, 2019

Could not begin read transaction (maximum of read transactions reached)

@guqh
Copy link
Author

guqh commented Aug 27, 2019

io.objectbox.exception.DbMaxReadersExceededException: Could not begin read transaction (maximum of read transactions reached) (error code -30790)

@guqh
Copy link
Author

guqh commented Aug 27, 2019

image
这样的写法,查询完数据后,需要去释放资源吗?

@guqh
Copy link
Author

guqh commented Aug 27, 2019

image

@greenrobot-team
Copy link
Member

@guqh Is this a follow-up with more information from #748? In any case, thanks for the additional details, we'll have a look.

@guqh
Copy link
Author

guqh commented Aug 27, 2019

Original: 对的是一个问题,是否query 后需要手动释放资源?

Translation: The right thing is a question. Is it necessary to manually release resources after query?

@guqh
Copy link
Author

guqh commented Aug 27, 2019

image
Original: 是否要这样每次 query 后 ,需要close 这个query
Translation: Do you want to close this query after each query?

@greenrobot
Copy link
Member

Does query.close() help to resolve your issue?

However, best practice is to cache and reuse the Query object (do not always create a new one).

@guqh
Copy link
Author

guqh commented Aug 27, 2019

Original:
是我每一张表都创建一个 box.query()放到全局变量,需要的地方全部调用这个?还是box.query()....build() 后这个query进行重用,那这个不同的条件是没办法重用的!

还有您说的缓存具体是指什么?

Translation:
Is it that I create a box.query() for each table and put it in a global variable, all that is needed to call this? After the box.query()....build(), the query is reused, and the different conditions are not reusable!

What else do you mean by the cache?

@guqh
Copy link
Author

guqh commented Aug 27, 2019

Original: 是我每次box.query()就会生成一个cursor还是?每次box.query()...build()后会生成一个新的cursor?

Translation: Is it every time I make a cursor in box.query() or does it generate a new cursor every time box.query()...build()?

@guqh
Copy link
Author

guqh commented Aug 27, 2019

Original: 是我每次box.query()就会生成一个cursor?还是每次box.query()...build()后会生成一个新的cursor?

Translation: Is every time my box.query() generates a cursor? Or does it generate a new cursor every time after box.query()...build()?

@guqh
Copy link
Author

guqh commented Aug 28, 2019

java.lang.IllegalStateException: This QueryBuilder has already been closed. Please use a new instance.

Original: 根本无法重用这个query

Translation: I can't reuse this query at all.

@guqh
Copy link
Author

guqh commented Aug 28, 2019

Please tell me how to release cursor resources.

@guqh
Copy link
Author

guqh commented Aug 28, 2019

What action will cursor be created and released manually?

@guqh guqh changed the title Cursor RxCachedThreadSchedules Cursor RxCachedThreadSchedules Storage error code -30790 Aug 28, 2019
@guqh
Copy link
Author

guqh commented Aug 28, 2019

image

Original: 请问这些 cursor 是在什么情况下创建

Translation: How are these cursors created under what circumstances?

@guqh
Copy link
Author

guqh commented Aug 28, 2019

image
Original: 这个泄漏怎么处理

Translation: How to deal with this leak

@guqh
Copy link
Author

guqh commented Aug 28, 2019

Original:
实际上我增大了 MaxReader 没有解决根本原因,只要进行自动化测试,压测过程中,这个query 对象会一直增长,持续的泄漏,由于qeury 对象的泄漏,持有的线程无法被释放,不仅导致了 30790 异常,并且导致oom,需要找到根本原因去解决这个问题,所以,想知道这个query 是怎么运行,怎么去释放这个资源?

Translation:
In fact, I have increased the MaxReader to solve the root cause. As long as the automated test, during the pressure test, the query object will continue to grow, continuous leakage, due to the leakage of the qeury object, the held thread can not be released, not only caused 30790 Exception, and lead to oom, need to find the root cause to solve this problem, so, I want to know how this query works, how to release this resource?

@guqh
Copy link
Author

guqh commented Aug 28, 2019

@greenrobot-team @greenrobot Please help me,Thank you very much!

@greenrobot
Copy link
Member

@guqh To better help you: can you tell us about the class from which you use the query? Is this class longer lived, e.g. Activity? Is the query run always from a the same thread?

@greenrobot-team We should prep some "code recipe" for this...

@greenrobot
Copy link
Member

Please check this example demonstrating the multi-threaded usage of cached query:
https://gist.github.com/greenrobot/6a1e818193c8b2d0a661dca5441ab94b

@guqh
Copy link
Author

guqh commented Aug 28, 2019

image
Original: 就像截图一下,每次查询都在我的子线程进行操作,当当前acitivity 销毁时,我们会释放rx 的disposableList

Translation: Just like a screenshot, every query is done in my child thread. When the current acitivity is destroyed, we will release the disposableList of rx.
@greenrobot

@guqh
Copy link
Author

guqh commented Aug 28, 2019

Original: 但是从自动化压测来看,是query 对象,没有释放,持有的rx线程导致无法释放,造成泄漏,累积会出现oom

Translation: But from the point of view of automated pressure measurement, it is a query object, there is no release, the rx thread held can not be released, causing a leak, and the accumulation will appear oom

@greenrobot
Copy link
Member

@guqh Did this example help, which I shared yesterday?

Please check this example demonstrating the multi-threaded usage of cached query:
https://gist.github.com/greenrobot/6a1e818193c8b2d0a661dca5441ab94b

@greenrobot-team
Copy link
Member

Closing this issue due to inactivity. 💤 Feel free to re-open with more details or submit a new issue.

@AnswerZhao
Copy link

@guqh 请问这个问题你当时怎么解决的,我现在在压测中也遇到这个问题了,native的内存占用一直在持续增长。

@JohnGuSir
Copy link

@guqh 请问这个问题你当时怎么解决的,我现在在压测中也遇到这个问题了,native的内存占用一直在持续增长。

记得好像是 rx java 使用不对,线程没有被释放,一直无限新增线程导致的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants