Skip to content

spanconfigstore: introduce a system span config store#76871

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
arulajmani:protectedts-system-spanconfig-store
Feb 23, 2022
Merged

spanconfigstore: introduce a system span config store#76871
craig[bot] merged 1 commit intocockroachdb:masterfrom
arulajmani:protectedts-system-spanconfig-store

Conversation

@arulajmani
Copy link
Copy Markdown
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

@arulajmani arulajmani requested a review from a team as a code owner February 22, 2022 05:02
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing err check

switch st.systemTargetType {
case SystemTargetTypeAllTenantKeyspaceTargetsSet:
if st.targetTenantID != nil {
if !st.targetTenantID.Equal(roachpb.TenantID{}) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 23, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
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.

3 participants