From fff3f55a58f0accb60706d8285a9fe72e0b1b2d7 Mon Sep 17 00:00:00 2001 From: liwang Date: Sun, 3 Nov 2024 22:56:48 -0800 Subject: [PATCH] ZOOKEEPER-4872: SnapshotCommand should not perform fastForwardFromEdits Author: Li Wang --- .../org/apache/zookeeper/server/ZooKeeperServer.java | 9 ++------- .../java/org/apache/zookeeper/server/admin/Commands.java | 2 +- .../zookeeper/server/ZookeeperServerRestoreTest.java | 2 +- .../zookeeper/server/ZookeeperServerSnapshotTest.java | 2 +- .../apache/zookeeper/server/admin/RestoreQuorumTest.java | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java index 6740f6d524b..8e291f86939 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java @@ -554,7 +554,7 @@ public File takeSnapshot() throws IOException { } public File takeSnapshot(boolean syncSnap) throws IOException { - return takeSnapshot(syncSnap, true, false); + return takeSnapshot(syncSnap, true); } /** @@ -562,18 +562,13 @@ public File takeSnapshot(boolean syncSnap) throws IOException { * * @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) { diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/admin/Commands.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/admin/Commands.java index 74dfdc3c113..cd5adc76ac6 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/admin/Commands.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/admin/Commands.java @@ -783,7 +783,7 @@ public CommandResponse runGet(final ZooKeeperServer zkServer, final Map