-
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,spanconfig,kvserver: ExportRequest noops on ranges excluded…
… from backup This change is the first of two changes that gets us to the goal of backup ignoring certain table row data, and not holding up GC on these ranges. This change does a few things: - It sets up the transport of the exclude_data_from_backup bit set on a table descriptor, to the span configuration applied in KV. - It teaches ExportRequest on a range marked as excluded to return an empty ExportResponse. In this way, a backup processor will receive no row data to backup up for an ephemeral table. - A follow up change will also teach the SQLTranslator to not populate the protected timestamp field on the SpanConfig for such tables. This way, a long running backup will not hold up GC on such high-churn tables. With no protection on such ranges, it is possible that an ExportRequest targetting the range has a StartTime below the range's GCThreshold. To avoid the returned BatchTimestampBeforeGCError from failing the backup we decorate the the error with information about the range being excluded from backup and handle the error in the backup processor. Informs: #73536 Release note (sql change): BACKUP of a table marked with `exclude_data_from_backup` via `ALTER TABLE ... SET (exclude_data_from_backup = true)` will no longer backup that table's row data. The backup will continue to backup the table's descriptor and related metadata, and so on restore we will end up with an empty version of the backed up table.
- Loading branch information
1 parent
7bd7ec0
commit 1fd9303
Showing
12 changed files
with
438 additions
and
3 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
52 changes: 52 additions & 0 deletions
52
pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/exclude_data_from_backup
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,52 @@ | ||
exec-sql | ||
CREATE DATABASE db; | ||
CREATE TABLE db.t1(); | ||
CREATE TABLE db.t2(); | ||
---- | ||
|
||
query-sql | ||
SELECT id FROM system.namespace WHERE name='t1' | ||
---- | ||
56 | ||
|
||
query-sql | ||
SELECT id FROM system.namespace WHERE name='t2' | ||
---- | ||
57 | ||
|
||
# We only expect there to be span config entries for tables t1 and t2. | ||
translate database=db | ||
---- | ||
/Table/5{6-7} range default | ||
/Table/5{7-8} range default | ||
|
||
# Alter table t1 to mark its data ephemeral. | ||
exec-sql | ||
ALTER TABLE db.t1 SET (exclude_data_from_backup = true) | ||
---- | ||
|
||
translate database=db | ||
---- | ||
/Table/5{6-7} exclude_data_from_backup=true | ||
/Table/5{7-8} range default | ||
|
||
# Translating the tables in the database individually should result in the same | ||
# config as above. | ||
|
||
translate database=db table=t1 | ||
---- | ||
/Table/5{6-7} exclude_data_from_backup=true | ||
|
||
translate database=db table=t2 | ||
---- | ||
/Table/5{7-8} range default | ||
|
||
# Alter table t1 to unmark its data ephemeral. | ||
exec-sql | ||
ALTER TABLE db.t1 SET (exclude_data_from_backup = false); | ||
---- | ||
|
||
translate database=db | ||
---- | ||
/Table/5{6-7} range default | ||
/Table/5{7-8} range default |
52 changes: 52 additions & 0 deletions
52
pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/tenant/exclude_data_from_backup
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,52 @@ | ||
exec-sql | ||
CREATE DATABASE db; | ||
CREATE TABLE db.t1(); | ||
CREATE TABLE db.t2(); | ||
---- | ||
|
||
query-sql | ||
SELECT id FROM system.namespace WHERE name='t1' | ||
---- | ||
56 | ||
|
||
query-sql | ||
SELECT id FROM system.namespace WHERE name='t2' | ||
---- | ||
57 | ||
|
||
# We only expect there to be span config entries for tables t1 and t2. | ||
translate database=db | ||
---- | ||
/Tenant/10/Table/5{6-7} range default | ||
/Tenant/10/Table/5{7-8} range default | ||
|
||
# Alter table t1 to mark its data ephemeral. | ||
exec-sql | ||
ALTER TABLE db.t1 SET (exclude_data_from_backup = true) | ||
---- | ||
|
||
translate database=db | ||
---- | ||
/Tenant/10/Table/5{6-7} exclude_data_from_backup=true | ||
/Tenant/10/Table/5{7-8} range default | ||
|
||
# Translating the tables in the database individually should result in the same | ||
# config as above. | ||
|
||
translate database=db table=t1 | ||
---- | ||
/Tenant/10/Table/5{6-7} exclude_data_from_backup=true | ||
|
||
translate database=db table=t2 | ||
---- | ||
/Tenant/10/Table/5{7-8} range default | ||
|
||
# Alter table t1 to unmark its data ephemeral. | ||
exec-sql | ||
ALTER TABLE db.t1 SET (exclude_data_from_backup = false); | ||
---- | ||
|
||
translate database=db | ||
---- | ||
/Tenant/10/Table/5{6-7} range default | ||
/Tenant/10/Table/5{7-8} range default |
Oops, something went wrong.