[
https://issues.apache.org/jira/browse/ZOOKEEPER-2722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15935175#comment-15935175
]
ASF GitHub Bot commented on ZOOKEEPER-2722:
-------------------------------------------
Github user afine commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/191#discussion_r107254406
--- Diff: src/java/test/org/apache/zookeeper/test/ClientBase.java ---
@@ -96,24 +96,34 @@ public void process(WatchedEvent event) { /* nada */ }
public static class CountdownWatcher implements Watcher {
// XXX this doesn't need to be volatile! (Should probably be final)
volatile CountDownLatch clientConnected;
+ // Set to true when connected to a read-only server, or a
read-write (quorum) server.
volatile boolean connected;
+ // Set to true when connected to a quorum server.
+ volatile boolean syncConnected;
public CountdownWatcher() {
reset();
}
synchronized public void reset() {
clientConnected = new CountDownLatch(1);
connected = false;
+ syncConnected = false;
}
synchronized public void process(WatchedEvent event) {
- if (event.getState() == KeeperState.SyncConnected ||
- event.getState() == KeeperState.ConnectedReadOnly) {
+ KeeperState state = event.getState();
+ if (state == KeeperState.SyncConnected) {
+ connected = true;
+ syncConnected = true;
+ } else if (state == KeeperState.ConnectedReadOnly) {
connected = true;
--- End diff --
but what if some event happens that causes the state to drop from
syncconnected -> connectedreadonly during a test (before reset is ever called).
If expecting a reset call was sufficient, we would not need the "else" clause
in that if statement right?
> Flaky Test:
> org.apache.zookeeper.test.ReadOnlyModeTest.testSessionEstablishment
> -------------------------------------------------------------------------------
>
> Key: ZOOKEEPER-2722
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2722
> Project: ZooKeeper
> Issue Type: Bug
> Components: tests
> Affects Versions: 3.4.9, 3.5.2
> Reporter: Michael Han
> Assignee: Michael Han
> Labels: flaky, flaky-build, flaky-test
> Fix For: 3.5.3, 3.6.0
>
>
> {noformat}
> Error Message
> KeeperErrorCode = ConnectionLoss for /test
> Stacktrace
> org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode
> = ConnectionLoss for /test
> at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
> at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
> at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1423)
> at
> org.apache.zookeeper.test.ReadOnlyModeTest.testSessionEstablishment(ReadOnlyModeTest.java:238)
> at
> org.apache.zookeeper.JUnit4ZKTestRunner$LoggedInvokeMethod.evaluate(JUnit4ZKTestRunner.java:79)
> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> at java.lang.Thread.run(Thread.java:745)
> {noformat}
> Looks like we should retry before giving up.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)