yfxhust commented on a change in pull request #1247: ZOOKEEPER-3713: 
ReadOnlyZooKeeperServer should not expose the uniniti…
URL: https://github.com/apache/zookeeper/pull/1247#discussion_r379328043
 
 

 ##########
 File path: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeer.java
 ##########
 @@ -1350,6 +1350,15 @@ public void run() {
                     ServerMetrics.getMetrics().LOOKING_COUNT.add(1);
 
                     if (Boolean.getBoolean("readonlymode.enabled")) {
+                        if (!zkDb.isInitialized()) {
 
 Review comment:
   Thank you for comments.
   Let's take Follower as example.
   In my understanding, QuorumPeer would shutdown FollowerZooKeeperServer and 
clear QuorumPeer's `follower` as null when there is issue during syncing with 
leader. This is as same as what you described. But the corresponding QuorumPeer 
is still alive and it will fall into ServerState.LOOKING. In the LOOKING state, 
it will start a new temporary ReadOnlyZooKeeperServer without syncing if 
`readonlymode.enabled` is set. QuorumPeer's lifecycle is different with the 
corresponding's FollowerZooKeeperServer's. That's the point that this PR want 
to resolve. During the ReadOnlyZooKeeperServer is serving, it possibly exposes 
the uninitialized zkDb to clients.
   If `readonlymode.enabled` is not set, I think it wont't move forward and 
always look for leader until successful.
   If I missed anything. please let me know. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to