-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
base: introduce SQLInstanceID (and container) #48110
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0290ec8
to
87cbf4b
Compare
This comment has been minimized.
This comment has been minimized.
f34f6b3
to
83ce9e9
Compare
❌ The GitHub CI (Cockroach) build has failed on 83ce9e95. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you planning on adding another commit to add the Optional
calls or will that be in another PR?
Reviewed 17 of 17 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)
TFTR! I'll do that here, I just wanted to get a first round of review before I make code changes that could potentially rot. Will ping again when it's ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 17 of 17 files at r1.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @tbg)
pkg/base/node_id.go, line 88 at r1 (raw file):
type SQLInstanceID int64 // IDContainer wraps a SQLInstanceID and optionally a NodeID.
Should this be called SQLIDContainer?
The key-value layer should never need one of these, so it's not a direct replacement for NodeIDContainer
.
pkg/base/node_id.go, line 116 at r1 (raw file):
fmt.Fprintf(&buf, "@n%s,", n) } return ""
I don't think this is what you meant.
With the advent of multi-tenancy, SQL servers can optionally be decoupled from the (and share a) KV backend. As a consequence, the NodeID may not be available and its use across all components that need to function in a multi-tenant setup is deprecated. Yet, some components require a similar unique identifier for the SQL server they're a part of. This new identifier is the SQLInstanceID. At the time of writing, since we're not yet able to start true SQL tenant servers and only exercise parts of this functionality in unit testing, it is a randomized integer. It's possible that we'll replace it with a per-tenant or even global counter in production, putting it truly on par with the NodeID, to be able to give the simple guarantee that these IDs are never reused between different incarnations of the SQL process for a given tenant. This final decision is kicked down the road, see cockroachdb#48009. This commit introduces an IDContainer which will aid this process by wrapping both the NodeID and SQLInstanceID, very similar to the work carried out for Gossip in cockroachdb#47972. We do not yet audit all of the call sites to keep the initial diff container. Instead, IDContainer has a Get() method that makes it a drop-in replacement for the previously used NodeIDContainer. `Get ` will be removed in a future commit while moving all callers to either the `Optional{,Err}` or `DeprecatedNodeID` methods. Release note: None
Release note: None
Release note: None
Release note: None
Release note: None
Release note: None
This is only used to log to the (per-tenant) event log. Release note: None
This allows its use for the cluster(= tenant's logical cluster)-wide unique IDs generator. Release note: None
Release note: None
Touches cockroachdb#47970. Release note: None
It's used to initialize a txn, where we want to pass zero if we don't have a NodeID. Release note: None
This comment has been minimized.
This comment has been minimized.
Release note: None
bors r=asubiotto,nvanbenschoten I packed on a lot of commits that remove uses of |
Build succeeded |
With the advent of multi-tenancy, SQL servers can optionally be
decoupled from the (and share a) KV backend. As a consequence, the
NodeID may not be available and its use across all components that need
to function in a multi-tenant setup is deprecated. Yet, some components
require a similar unique identifier for the SQL server they're a part
of.
This new identifier is the SQLInstanceID. At the time of writing,
since we're not yet able to start true SQL tenant servers and only
exercise parts of this functionality in unit testing, it is a
randomized integer. It's possible that we'll replace it with
a per-tenant counter in production, putting it truly on par with
the NodeID, to be able to give the simple guarantee that these IDs
are never reused between different incarnations of the SQL process
for a given tenant. (Note that initially, at most one SQL tenant
server will be active per tenant at any given time).
This commit introduces an IDContainer which will aid this process by
wrapping both the NodeID and SQLInstanceID, very similar to the work
carried out for Gossip in #47972. We do not yet audit all of the call
sites to keep the initial diff container. Instead, IDContainer has a
Get() method that makes it a drop-in replacement for the previously used
NodeIDContainer.
Get
will be removed in a future commit while movingall callers to either the
Optional{,Err}
orDeprecatedNodeID
methods.
Release note: None