Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZOOKEEPER-4872: SnapshotCommand should not perform fastForwardFromEdits #2210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -554,26 +554,21 @@ public File takeSnapshot() throws IOException {
}

public File takeSnapshot(boolean syncSnap) throws IOException {
return takeSnapshot(syncSnap, true, false);
return takeSnapshot(syncSnap, true);
}

/**
* Takes a snapshot on the server.
*
* @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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ public CommandResponse runGet(final ZooKeeperServer zkServer, final Map<String,

// 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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testRestoreFromSnapshot() throws Exception {
}

// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void testTakeSnapshot() throws Exception {
}

// takeSnapshot
zks.takeSnapshot(false, false, true);
zks.takeSnapshot(false, false);

// clean up
zk.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testRestoreAfterQuorumLost() throws Exception {

// 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
Expand Down
Loading