forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: support tenant creation and deletion, track in system.tenants table
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.
- Loading branch information
1 parent
51f231f
commit 4272248
Showing
31 changed files
with
988 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,7 +217,7 @@ requesting database details for defaultdb... writing: debug/schema/defaultdb@det | |
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
26 tables found | ||
27 tables found | ||
requesting table details for system.comments... writing: debug/schema/system/comments.json | ||
requesting table details for system.descriptor... writing: debug/schema/system/descriptor.json | ||
requesting table details for system.eventlog... writing: debug/schema/system/eventlog.json | ||
|
@@ -240,6 +240,7 @@ requesting table details for system.statement_bundle_chunks... writing: debug/sc | |
requesting table details for system.statement_diagnostics... writing: debug/schema/system/statement_diagnostics.json | ||
requesting table details for system.statement_diagnostics_requests... writing: debug/schema/system/statement_diagnostics_requests.json | ||
requesting table details for system.table_statistics... writing: debug/schema/system/table_statistics.json | ||
requesting table details for system.tenants... writing: debug/schema/system/tenants.json | ||
requesting table details for system.ui... writing: debug/schema/system/ui.json | ||
requesting table details for system.users... writing: debug/schema/system/users.json | ||
requesting table details for system.web_sessions... writing: debug/schema/system/web_sessions.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,7 @@ requesting database details for defaultdb... writing: debug/schema/defaultdb@det | |
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
26 tables found | ||
27 tables found | ||
requesting table details for system.comments... writing: debug/schema/system/comments.json | ||
requesting table details for system.descriptor... writing: debug/schema/system/descriptor.json | ||
requesting table details for system.eventlog... writing: debug/schema/system/eventlog.json | ||
|
@@ -177,6 +177,7 @@ requesting table details for system.statement_bundle_chunks... writing: debug/sc | |
requesting table details for system.statement_diagnostics... writing: debug/schema/system/statement_diagnostics.json | ||
requesting table details for system.statement_diagnostics_requests... writing: debug/schema/system/statement_diagnostics_requests.json | ||
requesting table details for system.table_statistics... writing: debug/schema/system/table_statistics.json | ||
requesting table details for system.tenants... writing: debug/schema/system/tenants.json | ||
requesting table details for system.ui... writing: debug/schema/system/ui.json | ||
requesting table details for system.users... writing: debug/schema/system/users.json | ||
requesting table details for system.web_sessions... writing: debug/schema/system/web_sessions.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,7 @@ requesting database details for defaultdb... writing: debug/schema/defaultdb@det | |
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
26 tables found | ||
27 tables found | ||
requesting table details for system.comments... writing: debug/schema/system/comments.json | ||
requesting table details for system.descriptor... writing: debug/schema/system/descriptor.json | ||
requesting table details for system.eventlog... writing: debug/schema/system/eventlog.json | ||
|
@@ -176,6 +176,7 @@ requesting table details for system.statement_bundle_chunks... writing: debug/sc | |
requesting table details for system.statement_diagnostics... writing: debug/schema/system/statement_diagnostics.json | ||
requesting table details for system.statement_diagnostics_requests... writing: debug/schema/system/statement_diagnostics_requests.json | ||
requesting table details for system.table_statistics... writing: debug/schema/system/table_statistics.json | ||
requesting table details for system.tenants... writing: debug/schema/system/tenants.json | ||
requesting table details for system.ui... writing: debug/schema/system/ui.json | ||
requesting table details for system.users... writing: debug/schema/system/users.json | ||
requesting table details for system.web_sessions... writing: debug/schema/system/web_sessions.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ requesting table details for defaultdb.pg_catalog.pg_class... writing: debug/sch | |
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
26 tables found | ||
27 tables found | ||
requesting table details for system.comments... writing: debug/schema/system-1/comments.json | ||
requesting table details for system.descriptor... writing: debug/schema/system-1/descriptor.json | ||
requesting table details for system.eventlog... writing: debug/schema/system-1/eventlog.json | ||
|
@@ -44,6 +44,7 @@ requesting table details for system.statement_bundle_chunks... writing: debug/sc | |
requesting table details for system.statement_diagnostics... writing: debug/schema/system-1/statement_diagnostics.json | ||
requesting table details for system.statement_diagnostics_requests... writing: debug/schema/system-1/statement_diagnostics_requests.json | ||
requesting table details for system.table_statistics... writing: debug/schema/system-1/table_statistics.json | ||
requesting table details for system.tenants... writing: debug/schema/system-1/tenants.json | ||
requesting table details for system.ui... writing: debug/schema/system-1/ui.json | ||
requesting table details for system.users... writing: debug/schema/system-1/users.json | ||
requesting table details for system.web_sessions... writing: debug/schema/system-1/web_sessions.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,7 @@ requesting database details for defaultdb... writing: debug/schema/defaultdb@det | |
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
26 tables found | ||
27 tables found | ||
requesting table details for system.comments... writing: debug/schema/system/comments.json | ||
requesting table details for system.descriptor... writing: debug/schema/system/descriptor.json | ||
requesting table details for system.eventlog... writing: debug/schema/system/eventlog.json | ||
|
@@ -114,6 +114,7 @@ requesting table details for system.statement_bundle_chunks... writing: debug/sc | |
requesting table details for system.statement_diagnostics... writing: debug/schema/system/statement_diagnostics.json | ||
requesting table details for system.statement_diagnostics_requests... writing: debug/schema/system/statement_diagnostics_requests.json | ||
requesting table details for system.table_statistics... writing: debug/schema/system/table_statistics.json | ||
requesting table details for system.tenants... writing: debug/schema/system/tenants.json | ||
requesting table details for system.ui... writing: debug/schema/system/ui.json | ||
requesting table details for system.users... writing: debug/schema/system/users.json | ||
requesting table details for system.web_sessions... writing: debug/schema/system/web_sessions.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.