Save Mutations in Range Partitioned Log Files for Backup V3#12752
Save Mutations in Range Partitioned Log Files for Backup V3#12752akankshamahajan15 wants to merge 4 commits intoapple:mainfrom
Conversation
f454532 to
b0372f6
Compare
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
b0372f6 to
8dcd539
Compare
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
|
Thanks for the detailed commit message. In the block header in addition to int32_t blockVersion = 5001 I think we should also have a checksum (e.g. crc32c) over the data in the block. This will help detect end to end problems in data transfer. We can also maintain a file-level checksum (perhaps computed over each block level checksum) stored in a trailer after the last block. If we end up with a backup with bad data in it this will help a) notify of this fact, and b) maybe help pinpoint where the corruption came from. This can be tested by generating a backup file to an in-memory target, then flipping a random bit in it, then uploading the file, then downloading / restoring it (presumably we put the checksum check in the download/restore logic somewhere). |
Yes, that should be doable and should work. Let me add that as well. |
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Discussed offline. My enthusiasm for the principle of end to end verification has caused me to forget the principle that we are backing up log files, so there is no discrete "start of this backup" and "end of this backup" and thus no clear "checksum for this backup". So for now, I think checksums on files only makes sense. On that point I do think that any new file format which is relied upon for data integrity (certainly this format counts) should build in application level checksumming in case of errors in dependent storage systems, errors in subsequent retrievals, etc. |
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Yes, I'm discussing it with Neethu for file level checksums and will add that in a separate/next PR. |
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
e5dd468 to
4f5bb22
Compare
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
4f5bb22 to
d129444
Compare
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
This PR implements saving mutations to range-partitioned backup log files.
Main Logic:
onBackupChangesis called with list of active backups.BackupWorkerupdates the backups map it maintains and removes stopped backups from the map.keyRangeToBackupAssignmentbased on intersection of backup's key range request and partitions key rangesIn
SaveMutationsToFile:keyRangeToBackupAssignmentto create the log file based, stores it inactiveFilesand records the mapping infileIndexByBackupPartitionMap of (backupUid, partitionId) -> index into activeFiles to make mutation routing easier.keyRangeToBackupAssignmentand appends the mutation to all log files usingfileIndexByBackupPartitionExample of keyRangetoFileIdxMap:
Each log files has
Each block has
TODO:
Pop and update saved version will be handled in next PR that implement s
uploadDatawhich will callsaveMutationsToFileandpopand updatesavedVersionaccordingly.Additional Note how everything works:
pullAsyncDatacontinuously pulls mutations from TLogs into an in-memory queueself->messageswhile the backup is running.BACKUP_WORKER_LOCK_BYTES(3GB default) caps the total estimated bytes of buffered messages; if the queue hits this limit, pulling blocks until uploads free space.uploadDatawakes roughly everyBACKUP_UPLOAD_DELAY(10 sec default) seconds, scansself->messages, and uploads a prefix that ends on a safe, committed version boundary usingsaveMutationsToFile.In the current code (V2 and V3 backup),
onBackupChangesandsaveMutationsToFilecan run at the same time, so a backup may be marked “stopped” while a file write is already in progress, and that in‑flight write can still include one last batch of data for it. This race is expected and benign: the stopped backup might get one extra file, but backup progress only moves forward, so we never miss or corrupt any data that should be backed up, and we don’t create gaps, just possibly a bit more data than strictly necessaryTesting
Wrote a simple test using mock and it creates a file: