Skip to content

Commit

Permalink
WT-6141 Disable checkpoint deletion during backup (#5616)
Browse files Browse the repository at this point in the history
* WT-6141 Disable checkpoint deletion during backup

Keep all WiredTiger checkpoints while a hot backup is active.

Also disables a pair of tests that checked for the old behavior.

Co-authored-by: Keith A. Smith <keith.smith@mongodb>
  • Loading branch information
keitharnoldsmith and Keith A. Smith committed May 7, 2020
1 parent 5f744db commit 2fd8209
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
15 changes: 11 additions & 4 deletions src/txn/txn_ckpt.c
Expand Up @@ -1259,12 +1259,19 @@ __checkpoint_lock_dirty_tree_int(WT_SESSION_IMPL *session, bool is_checkpoint, b
continue;
is_wt_ckpt = WT_PREFIX_MATCH(ckpt->name, WT_CHECKPOINT);

/*
* If there is a hot backup, don't delete any WiredTiger checkpoint that could possibly have been
* created before the backup started. Fail if trying to delete any other named checkpoint.
*/
#ifdef DISABLED_CODE
if (conn->hot_backup_start != 0 && ckpt->sec <= conn->hot_backup_start) {
#else
/*
* If there is a hot backup, don't delete any WiredTiger checkpoint that could possibly have
* been created before the backup started. Fail if trying to delete any other named
* checkpoint.
* N.B. Despite the comment above, dropping checkpoints during backup can corrupt the
* backup. For now we retain all WiredTiger checkpoints.
*/
if (conn->hot_backup_start != 0 && ckpt->sec <= conn->hot_backup_start) {
if (conn->hot_backup_start != 0) {
#endif
if (is_wt_ckpt) {
F_CLR(ckpt, WT_CKPT_DELETE);
continue;
Expand Down
13 changes: 8 additions & 5 deletions test/suite/test_backup01.py
Expand Up @@ -192,12 +192,15 @@ def test_checkpoint_delete(self):
# Confirm that a named checkpoint created after a backup cursor can be dropped.
# Need to pause a couple seconds; checkpoints that are assigned the same timestamp as
# the backup will be pinned, even if they occur after the backup starts.

time.sleep(2)
self.session.checkpoint("name=four")
self.session.checkpoint("drop=(four)")
self.assertRaises(wiredtiger.WiredTigerError,
lambda: self.session.open_cursor(
self.objs[0][0], None, "checkpoint=four"))
# N.B. This test is temporarily disabled because deleting checkpoints during backup
# can corrupt the backup.
#self.session.checkpoint("name=four")
#self.session.checkpoint("drop=(four)")
#self.assertRaises(wiredtiger.WiredTigerError,
# lambda: self.session.open_cursor(
# self.objs[0][0], None, "checkpoint=four"))

# Confirm that after closing the backup cursor the original named checkpoint can
# be deleted.
Expand Down
5 changes: 4 additions & 1 deletion test/suite/test_checkpoint05.py
Expand Up @@ -76,7 +76,10 @@ def test_checkpoints_during_backup(self):
# is generous. But if WT isn't deleting checkpoints there would
# be about 30x more checkpoints here.
final_count = self.count_checkpoints()
self.assertTrue (final_count < initial_count * 3)

# N.B. This test is temporarily disabled because deleting checkpoints during backup
# can corrupt the backup.
# self.assertTrue (final_count < initial_count * 3)

self.session.close()

Expand Down

0 comments on commit 2fd8209

Please sign in to comment.