Bugfix for NPE when lazyLoading in findEach due to Garbage Collection#3046
Conversation
|
I think comes back to the design question around use of weak refs here for ToMany due to |
|
@rob-bygrave Yes, I developed the fix with Jonas. It took some time until we understand what happens here. In short words
As the Workaround showed us, it helps, when we hold the beans, so that they cannot be GC'ed. But we find it better, if we just discard the query result. |
|
I think we need to go back to the design around using weakRefs for beancollections in LoadManyBuffer and see if there is another design choice available there. |
|
We introduced weak refs with #2936 - Here I discovered, that the buffers could build long "chains", that keeps everything in memory and causing an OOM. This happens, if beans are skipped, due inheritance.
Yes, as mentioned in #2936, the OOM will not occor, if the buffers are aligned, so that we can keep hard references to BeanCollection. Fortunately, we have a (manual) tests to verify a new implementation ;) @rob-bygrave do you have an estimated timeline and a plan, how to proceed here in short and long term?
|
|
Ok, I think the plan will be to merge this in first, and then ponder the longer term options.
Yes, revisit the original problem and see if padding is an option. A more brutal option is to actually move away from supporting inheritance in Ebean (and instead leave that up to the application side). |
Hello Rob,
I have to admit, that for this issue to occur, some special cases have to come together, but the provided test somewhat reproduces it and I will do my best to try and explain what seems to be going on here.
We started seeing exceptions, like the one at the very end (taken from the failing test), in our application but didn't really know where they came from and how to reproduce them, since restarting that part of code did not reproduce the error. However one idea came to mind, which seems to be the case here:
null, resulting in ebean trying to fill a property on a non existing bean.The provided test sometimes shows this behaviour, although it does not reliably reproduce it. I sometimes had to manually start it multiple times until it fails (doesn't seem to fail when using IntelliJ's "Run until failure" mode).
Our suggested fix is to just ignore these cases, since the beans are not hard referenced anywhere and thus are assumed to not be required. The alternative solution would be hold a hard reference to these beans when fetching information on them (we did this in FOCONIS@8c77aef), however this seems like unnecessarily keeping things in heap which should be cleaned up anyway.
What are your thoughts on this matter?
All the best
Jonas