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

server: initialize DBContext with correct instance ID #97467

Merged
merged 2 commits into from
Feb 23, 2023
Merged

Conversation

stevendanna
Copy link
Collaborator

Before this change the DBContext in a tenant would always have a zero'd SQLInstanceID.

Note that for SQL pods not co-located on an KV-node, OptionalNodeID() should still return 0 and anything that requires a NodeID rather than an InstanceID should be using that method.

Informs: #96353

Epic: none

Release note: None

@stevendanna stevendanna requested a review from a team February 22, 2023 15:24
@stevendanna stevendanna requested review from a team as code owners February 22, 2023 15:24
@blathers-crl
Copy link

blathers-crl bot commented Feb 22, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

wow nice catch

@stevendanna
Copy link
Collaborator Author

bors r=knz

@j82w
Copy link
Contributor

j82w commented Feb 22, 2023

-- commits line 11 at r1:
This fixes: #96353

@j82w
Copy link
Contributor

j82w commented Feb 22, 2023

pkg/server/tenant.go line 1022 at r1 (raw file):

	dbCtx := kv.DefaultDBContext(stopper)
	dbCtx.NodeID = instanceIDContainer
	db := kv.NewDBWithContext(baseCfg.AmbientCtx, tcsFactory, clock, dbCtx)

Is it possible to add an assert or test to prevent future regressions?

@stevendanna
Copy link
Collaborator Author

bors cancel

@craig
Copy link
Contributor

craig bot commented Feb 22, 2023

Canceled.

@stevendanna
Copy link
Collaborator Author

@j82w Good call. I'll see what happens if I add a few assertion failures in places where we expect to have a sql instance ID.

stevendanna and others added 2 commits February 23, 2023 08:30
Before this change the DBContext in a tenant would always have a
zero'd SQLInstanceID.

Note that for SQL pods not co-located on an KV-node, OptionalNodeID()
should still return 0 and anything that requires a NodeID rather than
an InstanceID _should_ be using that method.

Informs: #96353

Epic: none

Release note: None
@stevendanna
Copy link
Collaborator Author

bors r=knz

@craig
Copy link
Contributor

craig bot commented Feb 23, 2023

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