Skip to content

server: initialize DBContext with correct instance ID#97467

Merged
craig[bot] merged 2 commits intomasterfrom
ssd/db-context
Feb 23, 2023
Merged

server: initialize DBContext with correct instance ID#97467
craig[bot] merged 2 commits intomasterfrom
ssd/db-context

Conversation

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

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
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

bors r=knz

@j82w
Copy link
Copy Markdown
Contributor

j82w commented Feb 22, 2023

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

@j82w
Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

bors cancel

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 22, 2023

Canceled.

@stevendanna
Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

bors r=knz

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