You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've been running a data structure modeled after PathChildrenCache for a while now on a path with ~2500 child nodes and using a async loading strategy very similar to the new POST_INITIALIZED_EVENT startup mode. I noticed a couple subtle race conditions that we've encountered in our own code - thought I'd share them back.
trun@5229c8c If a node is removed during startup (after getChildren() but before getDataAndStat()) the INITIALIZED_EVENT will never fire. Handling NONODE events fixes this.
trun@fb94530 Though highly unlikely, I think it's possible for the initialSet to appear to be fully initialized before all the getDataAndStat() calls have even been issued? Constructing the initialSet before issuing any getDataAndStat() calls eliminates this possibility.
trun@e4ddc6c Each call to maybeOfferInitializedEvent() loops over the entire initialSet, and since it's called after each updateInitialSet() this can get pretty expensive ( O(n2) ) with thousands of children. There doesn't seem to be much value in keeping the entire initialSet around so removing each node after it's loaded simplifies this check a great deal.
Also one simple bugfix (which may not even be necessary any more)...
trun@3385adb initialSet is keyed on node, not fullPath so this call was just a NOP before.
From Netflix/curator#261
We've been running a data structure modeled after PathChildrenCache for a while now on a path with ~2500 child nodes and using a async loading strategy very similar to the new POST_INITIALIZED_EVENT startup mode. I noticed a couple subtle race conditions that we've encountered in our own code - thought I'd share them back.
trun@5229c8c If a node is removed during startup (after getChildren() but before getDataAndStat()) the INITIALIZED_EVENT will never fire. Handling NONODE events fixes this.
trun@fb94530 Though highly unlikely, I think it's possible for the initialSet to appear to be fully initialized before all the getDataAndStat() calls have even been issued? Constructing the initialSet before issuing any getDataAndStat() calls eliminates this possibility.
trun@e4ddc6c Each call to maybeOfferInitializedEvent() loops over the entire initialSet, and since it's called after each updateInitialSet() this can get pretty expensive ( O(n2) ) with thousands of children. There doesn't seem to be much value in keeping the entire initialSet around so removing each node after it's loaded simplifies this check a great deal.
Also one simple bugfix (which may not even be necessary any more)...
trun@3385adb initialSet is keyed on node, not fullPath so this call was just a NOP before.
Originally reported by randgalt, imported from: POST_INITIALIZED_EVENT race conditions / optimizations
The text was updated successfully, but these errors were encountered: