]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commit
Auto-GarbageCollect on PurgeOldBackups and DeleteBackup (#6015)
authorPeter Dillinger <peterd@fb.com>
Sat, 9 Nov 2019 03:13:41 +0000 (19:13 -0800)
committerPeter Dillinger <peterd@fb.com>
Fri, 15 Nov 2019 20:15:12 +0000 (12:15 -0800)
commita6d418384d58212f57052fe21362e0f748e552ff
treef4a98f3432664a55c6536296277474bd4fffb8cf
parentcb1dc296551e01f33bdba8ba55f5fe73654269fc
Auto-GarbageCollect on PurgeOldBackups and DeleteBackup (#6015)

Summary:
Only if there is a crash, power failure, or I/O error in
DeleteBackup, shared or private files from the backup might be left
behind that are not cleaned up by PurgeOldBackups or DeleteBackup-- only
by GarbageCollect. This makes the BackupEngine API "leaky by default."
Even if it means a modest performance hit, I think we should make
Delete and Purge do as they say, with ongoing best effort: i.e. future
calls will attempt to finish any incomplete work from earlier calls.

This change does that by having DeleteBackup and PurgeOldBackups do a
GarbageCollect, unless (to minimize performance hit) this BackupEngine
has already done a GarbageCollect and there have been no
deletion-related I/O errors in that GarbageCollect or since then.

Rejected alternative 1: remove meta file last instead of first. This would in theory turn partially deleted backups into corrupted backups, but code changes would be needed to allow the missing files and consider it acceptably corrupt, rather than failing to open the BackupEngine. This might be a reasonable choice, but I mostly rejected it because it doesn't solve the legacy problem of cleaning up existing lingering files.

Rejected alternative 2: use a deletion marker file. If deletion started with creating a file that marks a backup as flagged for deletion, then we could reliably detect partially deleted backups and efficiently finish removing them. In addition to not solving the legacy problem, this could be precarious if there's a disk full situation, and we try to create a new file in order to delete some files. Ugh.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6015

Test Plan: Updated unit tests

Differential Revision: D18401333

Pulled By: pdillinger

fbshipit-source-id: 12944e372ce6809f3f5a4c416c3b321a8927d925
HISTORY.md
include/rocksdb/utilities/backupable_db.h
utilities/backupable/backupable_db.cc
utilities/backupable/backupable_db_test.cc