Browse Source

ZOOKEEPER-4872: SnapshotCommand should not perform fastForwardFromEdits

Reviewers: kezhuw
Author: li4wang
Closes #2210 from li4wang/ZOOKEEPER-4872
li4wang 5 months ago
parent
commit
3e02328048

+ 2 - 7
zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java

@@ -554,7 +554,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
     }
 
     public File takeSnapshot(boolean syncSnap) throws IOException {
-        return takeSnapshot(syncSnap, true, false);
+        return takeSnapshot(syncSnap, true);
     }
 
     /**
@@ -562,18 +562,13 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
      *
      * @param syncSnap syncSnap sync the snapshot immediately after write
      * @param isSevere if true system exist, otherwise throw IOException
-     * @param fastForwardFromEdits whether fast forward database to the latest recorded transactions
-     *
      * @return file snapshot file object
      * @throws IOException
      */
-    public synchronized File takeSnapshot(boolean syncSnap, boolean isSevere, boolean fastForwardFromEdits) throws IOException {
+    public synchronized File takeSnapshot(boolean syncSnap, boolean isSevere) throws IOException {
         long start = Time.currentElapsedTime();
         File snapFile = null;
         try {
-            if (fastForwardFromEdits) {
-                zkDb.fastForwardDataBase();
-            }
             snapFile = txnLogFactory.save(zkDb.getDataTree(), zkDb.getSessionWithTimeOuts(), syncSnap);
         } catch (IOException e) {
             if (isSevere) {

+ 1 - 1
zookeeper-server/src/main/java/org/apache/zookeeper/server/admin/Commands.java

@@ -783,7 +783,7 @@ public class Commands {
 
             // take snapshot and stream out data if needed
             try {
-                final File snapshotFile = zkServer.takeSnapshot(false, false, true);
+                final File snapshotFile = zkServer.takeSnapshot(false, false);
                 final long lastZxid = Util.getZxidFromName(snapshotFile.getName(), SNAPSHOT_FILE_PREFIX);
                 response.addHeader(RESPONSE_HEADER_LAST_ZXID, "0x" + ZxidUtils.zxidToString(lastZxid));
 

+ 1 - 1
zookeeper-server/src/test/java/org/apache/zookeeper/server/ZookeeperServerRestoreTest.java

@@ -74,7 +74,7 @@ public class ZookeeperServerRestoreTest extends ZKTestCase {
             }
 
             // take Snapshot
-            final File snapshotFile = zks.takeSnapshot(false, false, true);
+            final File snapshotFile = zks.takeSnapshot(false, false);
             final long lastZxidFromSnapshot = Util.getZxidFromName(snapshotFile.getName(), SNAPSHOT_FILE_PREFIX);
 
             // zk2 create more test data after snapshotting

+ 1 - 1
zookeeper-server/src/test/java/org/apache/zookeeper/server/ZookeeperServerSnapshotTest.java

@@ -62,7 +62,7 @@ public class ZookeeperServerSnapshotTest extends ZKTestCase {
             }
 
             // takeSnapshot
-            zks.takeSnapshot(false, false, true);
+            zks.takeSnapshot(false, false);
 
             // clean up
             zk.close();

+ 1 - 1
zookeeper-server/src/test/java/org/apache/zookeeper/server/admin/RestoreQuorumTest.java

@@ -85,7 +85,7 @@ public class RestoreQuorumTest extends QuorumPeerTestBase {
 
             // create more data after restore
             for (int i = NODE_COUNT * 2; i < NODE_COUNT * 3; i++) {
-                servers.zk[leaderId].create(PATH + "/" + i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
+                servers.zk[leaderId].create(PATH + "/" + i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
             }
 
             // validate all servers have expected data