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

spanconfigsqltranslator: populate protected_timestamps in SpanConfig #74803

Merged
merged 1 commit into from
Jan 26, 2022

Conversation

adityamaru
Copy link
Contributor

@adityamaru adityamaru commented Jan 13, 2022

This change teaches the SQLTranslator to hydrate the SpanConfigs
for a table with protected timestamps that apply to that table.

Concretely, this change initializes a spanconfig.ProtectedTimestampStateReader
in the txn in which the translation is taking place, thereby
providing a transactional view of the system.protected_ts_records
table. After generating the span configurations based on the zone
configurations that apply to the table, we hydrate the newly
introduced protected_timestamps field on each span configuration
with all the protected timestamps that apply to this table. This
includes protected timestamp records that directly target this
table, as well as records targetting the table's parent database.
This information is obtained from the ProtectedTimestampStateReader
mentioned above.

Additionally, this change modifies StartTenant to allow secondary
tenants to interact with the protected timestamp subsystem using a
"real" protectedts.Provider provided the migration
EnableProtectedTimestampsForTenant has run.

For testing purposes, this change teaches the data driven framework
of two additional commands protect and release.

Informs: #73727

Release note: None

@adityamaru adityamaru requested review from a team as code owners January 13, 2022 16:52
@adityamaru adityamaru requested review from dt and otan and removed request for a team January 13, 2022 16:52
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@adityamaru adityamaru requested review from a team and srosenberg and removed request for a team and otan January 13, 2022 16:52
@adityamaru
Copy link
Contributor Author

First two commits are from #74737.

// ProtectedTimestamps captures all the protected timestamp records that apply
// to the range. The timestamp values represent the timestamps after which
// data will be protected from GC, if the protection succeeds.
repeated util.hlc.Timestamp protected_timestamps = 10 [(gogoproto.nullable) = false];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is subject to change in #74765

@adityamaru
Copy link
Contributor Author

@arulajmani @irfansharif this should be RFAL!

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.

LGTM mod comments below.

@irfansharif irfansharif removed the request for review from srosenberg January 24, 2022 15:06
@adityamaru adityamaru force-pushed the full-translate-contd branch 2 times, most recently from 34db9a9 to 29a4a03 Compare January 25, 2022 14:58
Copy link
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 22 files at r7, 19 of 22 files at r8, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @adityamaru, @ajwerner, @dt, and @irfansharif)


pkg/clusterversion/cockroach_versions.go, line 386 at r8 (raw file):

		Version: roachpb.Version{Major: 21, Minor: 2, Internal: 48},
	},
	{

To confirm, it's okay for us to do this now because we haven't released any betas?


pkg/spanconfig/spanconfigsqltranslator/sqltranslator.go, line 376 at r8 (raw file):

		// Copy the ProtectionPolicies that apply to the table's SpanConfig onto its
		// SubzoneSpanConfig.
		subzoneSpanConfig.GCPolicy.ProtectionPolicies = tableSpanConfig.GCPolicy.ProtectionPolicies[:]

nit: would it be clearer if you pulled the right hand side of the assignment in a separate variable and used it to assign the ProtectionPolicies wherever you need to?

@irfansharif
Copy link
Contributor

To confirm, it's okay for us to do this now because we haven't released any betas?

Yes, but also because we don't support upgrades from alphas/betas to prod clusters. Re-ordering these versions is safe any time before the actual release itself (not even the branch cut).

@@ -11,6 +11,8 @@ SELECT node_id, name FROM crdb_internal.leases ORDER BY name
0 eventlog
0 jobs
0 locations
0 protected_ts_meta
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, what's this about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not a 100% sure, but a little digging led me to #69008 where we switched to leasing all system descriptors except a few in a deny list. The PTS tables are not in this deny list so I guess we expect to see them here?

@adityamaru
Copy link
Contributor Author

nit: would it be clearer if you pulled the right hand side of the assignment in a separate variable and used it to assign the ProtectionPolicies wherever you need to?

Discussed offline, going to keep it as is for now since it avoids an extra copy.

This change teaches the SQLTranslator to hydrate the SpanConfigs
for a table with protected timestamps that apply to that table.

Concretely, this change initializes a spanconfig.ProtectedTimestampStateReader
in the txn in which the translation is taking place, thereby
providing a transactional view of the system.protected_ts_records
table. After generating the span configurations based on the zone
configurations that apply to the table, we hydrate the newly
introduced protected_timestamps field on each span configuration
with all the protected timestamps that apply to this table. This
includes protected timestamp records that directly target this
table, as well as records targetting the table's parent database.
This information is obtained from the ProtectedTimestampStateReader
mentioned above.

Additionally, this change modifies StartTenant to allow secondary
tenants to interact with the protected timestamp subsystem using a
"real" protectedts.Provider provided the migration
EnableProtectedTimestampsForTenant has run.

For testing purposes, this change teaches the data driven framework
of two additional commands protect and release.

Informs: cockroachdb#73727

Release note: None
@adityamaru
Copy link
Contributor Author

Bazel timeout seems unrelated.
TFTRs!

bors r=irfansharif,arulajmani

@craig
Copy link
Contributor

craig bot commented Jan 26, 2022

Build succeeded:

@craig craig bot merged commit 8f15635 into cockroachdb:master Jan 26, 2022
@adityamaru adityamaru deleted the full-translate-contd branch January 26, 2022 14:59
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