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

spanconfigstore: introduce a system span config store #76871

Merged

Conversation

arulajmani
Copy link
Collaborator

This patch introduces an in-memory datastructure to keep track of
system span configurations. This thing is consulted every time we fetch
the span configuration for a key to hydrate PTS information. In
particular, when fetching span configurations, we combine PTS
information stored on any system span configurations that may apply to
the given key with the PTS information stored on the key's associated
"regular" span config.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@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.

I still have to look at test files, will do that in between meetings. No blocking comments yet. I really like how "simple" this change is, I was expecting something much scarier but I guess most of that was frontloaded.

case update.Target.IsSystemTarget():
systemSpanConfigStoreUpdates = append(systemSpanConfigStoreUpdates, update)
default:
panic("unknown target type")
Copy link
Contributor

Choose a reason for hiding this comment

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

worth returning an error instead, considering the signature already supports it?


deletedSystemTargets, addedSystemSpanConfigRecords, err := s.mu.systemSpanConfigStore.apply(
systemSpanConfigStoreUpdates...,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

missing err check

@@ -189,7 +189,7 @@ func (st SystemTarget) encode() roachpb.Span {
func (st SystemTarget) validate() error {
switch st.systemTargetType {
case SystemTargetTypeAllTenantKeyspaceTargetsSet:
if st.targetTenantID != nil {
if !st.targetTenantID.Equal(roachpb.TenantID{}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the IsSet method in tenant.go here and everywhere else we perform these comparisons with roachpb.TenantID{}?

}

// combine takes a key and an associated span configuration and combines it with
// all system span configs that apply to the given key.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: extra space

return roachpb.SpanConfig{}, err
}
// Construct a list of system targets that apply to the key given its tenant
// prefix.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe explicity write out the three targets we want to check against, as part of this comment? Might be helpful for future readers even though the constructor methods are quite intuitively named now.

@adityamaru adityamaru self-requested a review February 22, 2022 15:02
Copy link
Contributor

@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.

Tests also LGTM to me!

// Ten 10 -> Ten 10: 200
// Ten 20 -> Ten 20: 300
//
// Span config: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

am I just missing it or is this SpanConfig entry missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh or is this the SpanConfig we combine with below?

This patch introduces an in-memory datastructure to keep track of
system span configurations. This thing is consulted every time we fetch
the span configuration for a key to hydrate PTS information. In
particular, when fetching span configurations, we combine PTS
information stored on any system span configurations that may apply to
the given key with the PTS information stored on the key's associated
"regular" span config.

Release note: None
@arulajmani arulajmani force-pushed the protectedts-system-spanconfig-store branch from 0aa60fe to d11b185 Compare February 22, 2022 23:57
Copy link
Collaborator Author

@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.

TFTR! Will bors on green

Dismissed @adityamaru from 3 discussions.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @adityamaru and @irfansharif)


pkg/spanconfig/systemtarget.go, line 192 at r1 (raw file):

Previously, adityamaru (Aditya Maru) wrote…

Can we use the IsSet method in tenant.go here and everywhere else we perform these comparisons with roachpb.TenantID{}?

Good call; done.


pkg/spanconfig/spanconfigstore/store.go, line 138 at r1 (raw file):

Previously, adityamaru (Aditya Maru) wrote…

worth returning an error instead, considering the signature already supports it?

Done.


pkg/spanconfig/spanconfigstore/store.go, line 159 at r1 (raw file):

Previously, adityamaru (Aditya Maru) wrote…

missing err check

Done.


pkg/spanconfig/spanconfigstore/systemspanconfigstore.go, line 93 at r1 (raw file):

Previously, adityamaru (Aditya Maru) wrote…

nit: Maybe explicity write out the three targets we want to check against, as part of this comment? Might be helpful for future readers even though the constructor methods are quite intuitively named now.

Done


pkg/spanconfig/spanconfigstore/systemspanconfigstore_test.go, line 56 at r1 (raw file):

Previously, adityamaru (Aditya Maru) wrote…

Oh or is this the SpanConfig we combine with below?

Yup, exactly, it's the SpanConfig I'm combining with below.

@arulajmani
Copy link
Collaborator Author

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 23, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Feb 23, 2022

Build succeeded:

@craig craig bot merged commit 1d13605 into cockroachdb:master Feb 23, 2022
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.

None yet

3 participants