Skip to content

Avoid marking objects as both live and disposed #178

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

Merged
merged 3 commits into from
May 30, 2016

Conversation

pontusmelke
Copy link
Contributor

In the ThreadCachingPool whenever an object is picked from the
ThreadLocal we cannot add it to the disposed queue directly since the
object will already be present in the live queue (or will be on release). Doing
that means that the object will be present both in the live and disposed
queue and also means that on reallocation we can multiple copies of the same
reference and can lead to that the live queue blows up in size.

@pontusmelke pontusmelke force-pushed the 1.0-thread-caching-bug branch 3 times, most recently from a52f03b to 76dd71b Compare May 26, 2016 08:41
In the `ThreadCachingPool` whenever an object is picked from the
`ThreadLocal` we cannot add it to the `disposed` queue directly since the
object will already be present in the `live` queue (or will be on release). Doing
that means that the object will be present both in the  `live` and `disposed`
queue and also means that on reallocation we can multiple copies of the same
reference and can lead to that the `live` queue blows up in size.
@pontusmelke pontusmelke force-pushed the 1.0-thread-caching-bug branch from 76dd71b to 246ebaa Compare May 26, 2016 13:01
Previously whenever an object was picked off the thread local cache it was
added back to the live queue even thought it was never removed from there.
This lead to indefinite growth of the live queue.

//This is terrible hack, but I really want to keep the queues private in
//ThreadCachingPool
private static MethodHandle queueGetter( String name )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indeed :) This seems acceptable to me, since it's in a test - but it does smell, and it smells like a missing abstraction. If we find ourselves digging deeper into this hole, one thing we could explore is to make the queues in the pool into some sort of service, so the pool takes an "ItemStorageService" or something that exposes the domain methods the pool is using the queues for. Then the test can inject its own "counting item storage" or whatever.

Something something back in my day we never did hacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakewins jakewins merged commit bd16b41 into neo4j:1.0 May 30, 2016
@jakewins
Copy link
Contributor

I'll forward-merge to 1.1 as well

pontusmelke added a commit to pontusmelke/neo4j-java-driver that referenced this pull request Jun 9, 2016
…ing-bug"

This reverts commit bd16b41, reversing
changes made to 9f3876a.
pontusmelke added a commit that referenced this pull request Jun 9, 2016
Revert "Merge pull request #178 from pontusmelke/1.0-thread-caching-bug"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants