forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 1
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 ephemeral ranges
This change is the first of two changes that gets us to the goal of backup ignoring ephemeral table row data, and not holding up GC on these ranges. This change does a few things: - It sets up the transport of the ephemeral bit set on a table descriptor via `ALTER TABLE ... SET EPHEMERAL DATA`, to the span configuration applied in KV. - It teaches ExportRequest on a range marked as ephemeral 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 ephemeral tables. This way, a long running backup will not hold up GC on such high-churn tables. With no protection on ephemeral ranges, it is possible that an ExportRequest targetting an ephemeral 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 ephemeral and handle the error in the backup processor. Informs: cockroachdb#73536 Release note (sql change): BACKUP of a table marked as `ephemeral` via `ALTER TABLE ... SET EPHEMERAL DATA` 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
54ac240
commit 9439375
Showing
12 changed files
with
294 additions
and
2 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/set_ephemeral_data
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 EPHEMERAL DATA | ||
---- | ||
|
||
translate database=db | ||
---- | ||
/Table/5{6-7} ephemeral_data=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} ephemeral_data=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 NOT EPHEMERAL DATA | ||
---- | ||
|
||
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/set_ephemeral_data
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 EPHEMERAL DATA | ||
---- | ||
|
||
translate database=db | ||
---- | ||
/Tenant/10/Table/5{6-7} ephemeral_data=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} ephemeral_data=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 NOT EPHEMERAL DATA | ||
---- | ||
|
||
translate database=db | ||
---- | ||
/Tenant/10/Table/5{6-7} range default | ||
/Tenant/10/Table/5{7-8} range default |
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
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
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
Oops, something went wrong.