You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by "kezhuw (via GitHub)" <gi...@apache.org> on 2024/09/10 03:38:10 UTC

Re: [PR] ZOOKEEPER-4813: Make zookeeper start successfully when the last log file is dirty during the restore progress [zookeeper]

kezhuw commented on code in PR #2144:
URL: https://github.com/apache/zookeeper/pull/2144#discussion_r1751202609


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/FileTxnLog.java:
##########
@@ -708,7 +708,16 @@ public long getStorageSize() {
         private boolean goToNextLog() throws IOException {
             if (storedFiles.size() > 0) {
                 this.logFile = storedFiles.remove(storedFiles.size() - 1);
-                ia = createInputArchive(this.logFile);
+                try {
+                    ia = createInputArchive(this.logFile);
+                } catch (EOFException e) {
+                    if (storedFiles.isEmpty()) {
+                        LOG.warn("The last log file {} EOF when create input archive, delete it.", logFile.getName(), e);
+                        logFile.deleteOnExit();

Review Comment:
   This is somewhat risky. It is not guaranteed that the deletion will ever happen. So it is possible this could introduce partially written file in median of log files.



-- 
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: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org