zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MichaelScofield <...@git.apache.org>
Subject [GitHub] zookeeper issue #584: ZOOKEEPER-3102: Potential race condition when create e...
Date Thu, 09 Aug 2018 02:47:08 GMT
Github user MichaelScofield commented on the issue:

    @anmolnar Sorry for the late response. I think what @lvfangmin wants to put here, is that
`createNode()` is called in single thread, so the race condition does not exist. **IF** there
were multi-threaded call, a lot of codes would have broken, including the `killSession()`.
    However, the original code might have synchronized on a wrong `list`:
    HashSet<String> list = ephemerals.get(ephemeralOwner);
    if (list == null) {
        list = new HashSet<String>();
        ephemerals.put(ephemeralOwner, list);
    // the "list" here is assumed to be contented, if it's created or altered elsewhere
    // (not bounded by the single-threaded guarantee), we might have synchronized
    // on a wrong object (that we just created).
    synchronized (list) {
    I'm just trying to make the codes look more robust. 


View raw message