Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrations: add target column to system.pts_records #74281

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

adityamaru
Copy link
Contributor

@adityamaru adityamaru commented Dec 24, 2021

This change adds a BYTES column to the system.pts_records
table, that will store an encoded protocol buffer
representing the Target on a protected timestamp
record. We do not populate the column in this PR, that will
be done in a followup.

Additionally, we add a tenant migration to ALTER TABLE ... ADD COLUMN
to run on the upgrade path for older clusters.

Informs: #73727

Release note (sql change): system.protected_timestamp_records table
now has an additional target column that will store an encoded
protobuf that represents the target a record protects. This target
can either be the entire cluster, tenants, or schema objects
(databases/tables).

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@adityamaru
Copy link
Contributor Author

First commit is from #74211.

@adityamaru adityamaru force-pushed the add-migration-to-pts-table branch from b963f58 to a5057c6 Compare December 28, 2021 02:52
@adityamaru adityamaru force-pushed the add-migration-to-pts-table branch from a5057c6 to 91e7bad Compare January 4, 2022 15:54
@adityamaru adityamaru marked this pull request as ready for review January 4, 2022 16:18
@adityamaru adityamaru requested a review from a team January 4, 2022 16:18
@adityamaru adityamaru requested review from a team as code owners January 4, 2022 16:18
@adityamaru adityamaru requested review from a team and shermanCRL and removed request for a team and shermanCRL January 4, 2022 16:18
@adityamaru adityamaru force-pushed the add-migration-to-pts-table branch from 91e7bad to ce46759 Compare January 4, 2022 18:23
@adityamaru
Copy link
Contributor Author

@arulajmani @irfansharif rebased and RFAL!

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Note also in the PR message that the target column will store an encoded protocol buffer?

pkg/sql/catalog/systemschema/system.go Outdated Show resolved Hide resolved
Copy link
Contributor

@irfansharif irfansharif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @adityamaru and @arulajmani)


pkg/migration/migrations/alter_table_protected_timestamp_records_test.go, line 64 at r1 (raw file):

	// Inject the old copy of the descriptor.
	migrations.InjectLegacyTable(ctx, t, s, systemschema.ProtectedTimestampsRecordsTable, getDeprecatedProtectedTimestampRecordsDescriptor)

[nit] Line wrap.


pkg/migration/migrations/alter_table_protected_timestamp_records_test.go, line 66 at r1 (raw file):

	migrations.InjectLegacyTable(ctx, t, s, systemschema.ProtectedTimestampsRecordsTable, getDeprecatedProtectedTimestampRecordsDescriptor)
	// Validate that the protected timestamp records table has the old schema.
	migrations.ValidateSchemaExists(

[nit] Wrap this in a tiny helper func:

validateSchemaExists := func (exp bool) { ...}
// ...

validateSchemaExists(false)
migrations.Migrate(...)
validateSchemaExists(true)

pkg/migration/migrations/alter_table_protected_timestamp_records_test.go, line 99 at r1 (raw file):

}

// getDeprecatedTableStatisticsDescriptor returns the system.table_statistics

Comment needs to be updated.

@adityamaru adityamaru force-pushed the add-migration-to-pts-table branch from ce46759 to 9c2e0c8 Compare January 5, 2022 04:01
Copy link
Contributor Author

@adityamaru adityamaru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @arulajmani, and @irfansharif)


pkg/migration/migrations/alter_table_protected_timestamp_records_test.go, line 64 at r1 (raw file):

Previously, irfansharif (irfan sharif) wrote…

[nit] Line wrap.

Done.


pkg/migration/migrations/alter_table_protected_timestamp_records_test.go, line 66 at r1 (raw file):

Previously, irfansharif (irfan sharif) wrote…

[nit] Wrap this in a tiny helper func:

validateSchemaExists := func (exp bool) { ...}
// ...

validateSchemaExists(false)
migrations.Migrate(...)
validateSchemaExists(true)

Done.


pkg/migration/migrations/alter_table_protected_timestamp_records_test.go, line 99 at r1 (raw file):

Previously, irfansharif (irfan sharif) wrote…

Comment needs to be updated.

Done.

This change adds a `BYTES` column to the system.pts_records
table, that will store an encoded protocol buffer
representing the `Target` on a protected timestamp
record. We do not populate the column in this PR, that will
be done in a followup.

Additionally, we add a tenant migration to `ALTER TABLE ... ADD COLUMN`
to run on the upgrade path for older clusters.

Informs: cockroachdb#73727

Release note (sql change): `system.protected_timestamp_records` table
now has an additional `target` column that will store an encoded
protobuf that represents the target a record protects. This target
can either be the entire cluster, tenants, or schema objects
(databases/tables).
@adityamaru adityamaru force-pushed the add-migration-to-pts-table branch from 9c2e0c8 to cdb829c Compare January 5, 2022 04:04
@adityamaru
Copy link
Contributor Author

TFTR!

bors r=ajwerner,irfansharif

craig bot pushed a commit that referenced this pull request Jan 5, 2022
74281: migrations: add target column to system.pts_records r=ajwerner,irfansharif a=adityamaru

This change adds a `BYTES` column to the system.pts_records
table, that will store an encoded protocol buffer
representing the `Target` on a protected timestamp
record. We do not populate the column in this PR, that will
be done in a followup.

Additionally, we add a tenant migration to `ALTER TABLE ... ADD COLUMN`
to run on the upgrade path for older clusters.

Informs: #73727

Release note (sql change): `system.protected_timestamp_records` table
now has an additional `target` column that will store an encoded
protobuf that represents the target a record protects. This target
can either be the entire cluster, tenants, or schema objects
(databases/tables).

Co-authored-by: Aditya Maru <[email protected]>
@craig
Copy link
Contributor

craig bot commented Jan 5, 2022

Build failed:

@adityamaru
Copy link
Contributor Author

TestComposeGSS flake

bors r=ajwerner,irfansharif

craig bot pushed a commit that referenced this pull request Jan 5, 2022
74281: migrations: add target column to system.pts_records r=ajwerner,irfansharif a=adityamaru

This change adds a `BYTES` column to the system.pts_records
table, that will store an encoded protocol buffer
representing the `Target` on a protected timestamp
record. We do not populate the column in this PR, that will
be done in a followup.

Additionally, we add a tenant migration to `ALTER TABLE ... ADD COLUMN`
to run on the upgrade path for older clusters.

Informs: #73727

Release note (sql change): `system.protected_timestamp_records` table
now has an additional `target` column that will store an encoded
protobuf that represents the target a record protects. This target
can either be the entire cluster, tenants, or schema objects
(databases/tables).

74418: authors: add sherman-grewal to authors r=sherman-grewal a=sherman-grewal

Release note: None

Co-authored-by: Aditya Maru <[email protected]>
Co-authored-by: Sherman Grewal <[email protected]>
@craig
Copy link
Contributor

craig bot commented Jan 5, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jan 5, 2022

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants