Skip to content
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

ZOOKEEPER-1011:fix Java Barrier Documentation example's race condition issue and polish up the Barrier Documentation #618

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maoling
Copy link
Member

@maoling maoling commented Sep 5, 2018

  • This patch fix the race condition of double barrier and avoid the herd effect.
  • To focus on the core logic and keep the codes short and clean,don't consider some parameters check,connect loss,the timeout for wait ....etc.The thoughtful codes can be found in the implements of DistributedDoubleBarrier of curator-recipes.
  • For test,you can change the QTY in the barrierTest from small one(1,2,3) to large one(1000,5000,10000),then observer the printed log to check the correctness of this patch.
  • more details in ZOOKEEPER-1011 .Thanks for
    semihsalihoglu reporting this issue.

}
}
}
} while (false);
Copy link

Choose a reason for hiding this comment

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

considering spurious wakeup, you should always use while(true) here, or change if (!hasBeenNotified.get()) to while (!hasBeenNotified.get())
https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--

Copy link
Member Author

Choose a reason for hiding this comment

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

@nameof
you can test this code by printing some logs to verify the correctness(wrong) of what you think(hahaha)

…n issue and polish up the Barrier Documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants