-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backupccl: handle range keys in BACKUP
Previously BACKUP would not back up range tombstones. With this patch, BACKUPs with revision_history will backup range tombstones. Non-revision history backups are not affected by this diff because MVCCExportToSST filters all tombstones out of the backup already. Specifically, this patch replaces the iterators used in the backup_processor with the pebbleIterator, which has baked in range key support. This refactor introduces a 5% regression in backup runtime, even when the backup has no range keys, though #83051 hopes to address this gap. See details below on the benchmark experiment. At this point a backup with range keys is restorable, thanks to #84214. Note that the restore codebase still touches iterators that are not range key aware. This is not a problem because restored data does not have range keys, nor do the empty ranges restore dumps data into. These iterators (e.g. in SSTBatcher and in CheckSSTConflicts) will be updated when #70428 gets fixed. Fixes #71155 Release note: none To benchmark this diff, the following commands were used on the following sha a5ccdc3, with and without this commit, over three trials: ``` roachprod create -n 5 --gce-machine-type=n2-standard-16 $CLUSTER roachprod put $CLUSTER [build] cockroach roachprod wipe $CLUSTER; roachprod start $CLUSTER; roachprod run $CLUSTER:1 -- "./cockroach workload init bank --rows 1000000000" roachprod sql $CLUSTER:1 -- -e "BACKUP INTO 'gs://somebucket/michael-rangkey?AUTH=implicit'" ``` The backup on the control binary took on average 478 seconds with a stdev of 13 seconds, while the backup with the treatment binary took on average 499 seconds with stddev of 8 seconds.
- Loading branch information
Showing
5 changed files
with
351 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Tests that Backups without Revisions History and Restore properly handle | ||
# range keys | ||
|
||
new-server name=s1 | ||
---- | ||
|
||
exec-sql | ||
CREATE DATABASE orig; | ||
USE orig; | ||
CREATE TABLE foo (i INT PRIMARY KEY, s STRING); | ||
INSERT INTO foo VALUES (1, 'x'),(2,'y'); | ||
CREATE TABLE baz (i INT PRIMARY KEY, s STRING); | ||
INSERT INTO baz VALUES (11, 'xx'),(22,'yy'); | ||
---- | ||
|
||
# Ensure a full backup properly captures range keys | ||
# - with foo, delete then insert, and ensure no original data surfaces in restore | ||
# - with baz: chill for now | ||
|
||
kv request=DeleteRange target=foo | ||
---- | ||
|
||
exec-sql | ||
INSERT INTO foo VALUES (3,'z'); | ||
---- | ||
|
||
exec-sql | ||
BACKUP INTO 'nodelocal://0/test-root/'; | ||
---- | ||
|
||
exec-sql | ||
RESTORE DATABASE orig FROM LATEST IN 'nodelocal://0/test-root/' with new_db_name='orig1'; | ||
---- | ||
|
||
query-sql | ||
SELECT count(*) from orig1.foo; | ||
---- | ||
1 | ||
|
||
query-sql | ||
SELECT count(*) from orig1.baz; | ||
---- | ||
2 | ||
|
||
exec-sql | ||
DROP DATABASE orig1 CASCADE | ||
---- | ||
|
||
# Ensure incremental backup without revision history | ||
# handles range tombstones: | ||
# - with foo, insert and ensure latest data from previous backup surfaces in RESTORE | ||
# - with baz, delete then insert, and ensure no data from previous backup surfaces in RESTORE | ||
|
||
exec-sql | ||
INSERT INTO foo VALUES (4,'a'),(5,'b'); | ||
---- | ||
|
||
kv request=DeleteRange target=baz | ||
---- | ||
|
||
exec-sql | ||
INSERT INTO baz VALUES (33,'zz'); | ||
---- | ||
|
||
exec-sql | ||
BACKUP INTO LATEST IN 'nodelocal://0/test-root/'; | ||
---- | ||
|
||
exec-sql | ||
RESTORE DATABASE orig FROM LATEST IN 'nodelocal://0/test-root/' with new_db_name='orig1'; | ||
---- | ||
|
||
query-sql | ||
SELECT count(*) from orig1.foo | ||
---- | ||
3 | ||
|
||
query-sql | ||
SELECT count(*) from orig1.baz | ||
---- | ||
1 | ||
|
||
|
||
|
Oops, something went wrong.