Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-4

POST_INITIALIZED_EVENT race conditions / optimizations

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.0.0-incubating
    • TBD
    • Recipes
    • None

    Description

      From https://github.com/Netflix/curator/pull/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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            randgalt Jordan Zimmerman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: