li4wang commented on code in PR #2185:
URL: https://github.com/apache/zookeeper/pull/2185#discussion_r1876700215
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java:
##########
@@ -618,9 +622,10 @@ public synchronized long restoreFromSnapshot(final
InputStream inputStream) thro
restoreLatch = new CountDownLatch(1);
try {
- // set to the new zkDatabase
- setZKDatabase(newZKDatabase);
-
+ synchronized (snapshotAndRestoreLock) {
+ // set to the new zkDatabase
+ setZKDatabase(newZKDatabase);
+ }
Review Comment:
```
protected void createSessionTracker() {
sessionTracker = new SessionTrackerImpl(this,
zkDb.getSessionWithTimeOuts(), tickTime, createSessionTrackerServerId,
getZooKeeperServerListener());
}
```
```
public File takeSnapshot(boolean syncSnap, boolean isSevere) throws
IOException {
try {
synchronized (snapshotAndRestoreLock) {
snapFile = txnLogFactory.save(zkDb.getDataTree(),
zkDb.getSessionWithTimeOuts(), syncSnap);
}
} catch (IOException e) {
```
```
public ConcurrentHashMap<Long, Integer> getSessionWithTimeOuts() {
return sessionsWithTimeouts;
}
```
`takeSapshot()` and `createSessionTracker() ` of `resore()` both read data
from the sessionsWithTimeouts ConcurrentHashMap, any reason the sync block need
to include it?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]