kezhuw commented on code in PR #2254:
URL: https://github.com/apache/zookeeper/pull/2254#discussion_r2122561575
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java:
##########
@@ -320,17 +323,30 @@ public void addCommittedProposal(Request request) {
WriteLock wl = logLock.writeLock();
try {
wl.lock();
- if (committedLog.size() > commitLogCount) {
- committedLog.remove();
- minCommittedLog = committedLog.peek().getZxid();
- }
if (committedLog.isEmpty()) {
minCommittedLog = request.zxid;
maxCommittedLog = request.zxid;
+ } else if (request.zxid <= maxCommittedLog) {
+ // This could happen if lastProcessedZxid is rewinded and
database is re-synced.
+ // Currently, it only happens in test codes, but it should
also be safe for production path.
Review Comment:
`LoadFromLogTest::testRestore` fails without this. Here is the javadoc of
the test.
```java
/**
* Test we can restore the snapshot that has data ahead of the zxid
* of the snapshot file.
*/
```
https://github.com/apache/zookeeper/blob/aeadf574c0463e7e3db092b588033d8347989d4c/zookeeper-server/src/test/java/org/apache/zookeeper/test/LoadFromLogTest.java#L178-L182
--
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]