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

sql: Remove cluster version input to GetInitialValues #48504

Merged

Conversation

nvanbenschoten
Copy link
Member

Addresses a TODO and helps clear the way for #47904.

This does not remove the rest of the references to VersionNamespaceTableWithSchemas.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@blathers-crl
Copy link

blathers-crl bot commented May 6, 2020

❌ The GitHub CI (Cockroach) build has failed on 502d837d.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl
Copy link

blathers-crl bot commented May 6, 2020

❌ The GitHub CI (Cockroach) build has failed on 502d837d.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

Addresses a TODO and helps clear the way for cockroachdb#47904.
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/bootstrapNamespace branch from 502d837 to c2dabe0 Compare May 6, 2020 21:22
@nvanbenschoten
Copy link
Member Author

Friendly ping.

nvanbenschoten added a commit to nvanbenschoten/cockroach that referenced this pull request May 13, 2020
Most of cockroachdb#47904.

First commit from cockroachdb#48504.
Second and third commit from cockroachdb#48773.

This commit implements the initial structure for tenant creation and
deletion. It does so by introducing a new system table to track tenants
in a multi-tenant cluster and two new builtin functions to manipulate
this table and the overall multi-tenant state.

The change starts by introducing a new `system.tenants` table with the
following schema:
```
CREATE TABLE system.tenants (
    id     INT8 NOT NULL PRIMARY KEY,
    active BOOL NOT NULL DEFAULT true,
    info   BYTES
);
```

The `id` column is self-explanatory. The `active` column is used to
coordinate tenant destruction in an asynchronous job. The `info` column
is an opaque byte slice to allow users to associate arbitrary
information with specific tenants. I don't know exactly how this third
field will be used (mapping tenants back to CockroachCloud user IDs?),
but it seems like a good idea to add some flexibility since we do intend
to eventually expose this externally.

The table is given an ID of 8, which means that it falls within the
"system config span". I believe this is ok, because the entire concept
of the "system config span" should be going away with cockroachdb#47150. The table
is also only exposed to the system-tenant and is never created for
secondary tenants.

The change then introduces two new builtin functions:
`crdb_internal.create_tenant` and `crdb_internal.destroy_tenant`. These
do what you would expect - creating and destroying tenant keyspaces,
along with updating metadata in system.tenants.
@tbg tbg requested a review from asubiotto May 13, 2020 09:49
@tbg
Copy link
Member

tbg commented May 13, 2020

@asubiotto can you take this one? Solon is off these days.

Copy link
Contributor

@asubiotto asubiotto left a comment

Choose a reason for hiding this comment

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

:lgtm: in principle but I've never interacted with this code before. cc @jordanlewis would you mind taking a quick look?

Reviewed 10 of 10 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @solongordon)

@nvanbenschoten
Copy link
Member Author

TFTR!

I didn't realize Solon was on paternity leave - I missed that on the calendar. I'll merge this now but am happy to revisit if someone else takes a look.

bors r+

@craig
Copy link
Contributor

craig bot commented May 13, 2020

Build succeeded

@craig craig bot merged commit ee733b3 into cockroachdb:master May 13, 2020
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/bootstrapNamespace branch May 14, 2020 16:15
nvanbenschoten added a commit to nvanbenschoten/cockroach that referenced this pull request May 14, 2020
Most of cockroachdb#47904.

First commit from cockroachdb#48504.
Second and third commit from cockroachdb#48773.

This commit implements the initial structure for tenant creation and
deletion. It does so by introducing a new system table to track tenants
in a multi-tenant cluster and two new builtin functions to manipulate
this table and the overall multi-tenant state.

The change starts by introducing a new `system.tenants` table with the
following schema:
```
CREATE TABLE system.tenants (
    id     INT8 NOT NULL PRIMARY KEY,
    active BOOL NOT NULL DEFAULT true,
    info   BYTES
);
```

The `id` column is self-explanatory. The `active` column is used to
coordinate tenant destruction in an asynchronous job. The `info` column
is an opaque byte slice to allow users to associate arbitrary
information with specific tenants. I don't know exactly how this third
field will be used (mapping tenants back to CockroachCloud user IDs?),
but it seems like a good idea to add some flexibility since we do intend
to eventually expose this externally.

The table is given an ID of 8, which means that it falls within the
"system config span". I believe this is ok, because the entire concept
of the "system config span" should be going away with cockroachdb#47150. The table
is also only exposed to the system-tenant and is never created for
secondary tenants.

The change then introduces two new builtin functions:
`crdb_internal.create_tenant` and `crdb_internal.destroy_tenant`. These
do what you would expect - creating and destroying tenant keyspaces,
along with updating metadata in system.tenants.
roachpb.KeyValue{
Key: NewPublicSchemaKey(desc.GetID()).Key(ms.codec),
Value: publicSchemaValue,
})
Copy link
Member

Choose a reason for hiding this comment

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

I thought this could be problematic given #49092, but I'm pretty sure it's not. This change simply edits what new clusters have as initial values. New clusters don't need anything for the old namespace table.

Does that square with your understanding @nvanbenschoten?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's correct. This is what new clusters use for their initial values.

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

5 participants