-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62053: sql: Add system table join_tokens, and create_join_tokens() builtin function r=knz a=itsbilal This change adds a new system table, `join_tokens`, for the exclusive use of storing join tokens. This is necessary as we need guaranteed at-most-once semantics with these, which transactions give us pretty easily. A related migration is also added to create said table This change also adds a new builtin function, `crdb_internal.create_join_token()` that creates and persists a join token in that table. Currently, there's no mechanism to remove expired join tokens. See RFC #51991. Part of #60632. Release note (general change): Add `crdb_internal.create_join_token()` sql builtin function to create join tokens for use when joining new nodes to a secure cluster. This functionality is hidden behind a feature flag. Co-authored-by: Bilal Akhtar <[email protected]>
- Loading branch information
Showing
46 changed files
with
505 additions
and
194 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
doctor cluster | ||
---- | ||
debug doctor cluster | ||
Examining 35 descriptors and 36 namespace entries... | ||
Examining 36 descriptors and 37 namespace entries... | ||
ParentID 50, ParentSchemaID 29: relation "foo" (53): expected matching namespace entry, found none | ||
Examining 1 running jobs... | ||
ERROR: validation failed |
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 |
---|---|---|
|
@@ -61,7 +61,7 @@ requesting goroutine files for node 1... writing: debug/nodes/1/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 36 found | ||
requesting ranges... 37 found | ||
writing: debug/nodes/1/ranges/1.json | ||
writing: debug/nodes/1/ranges/2.json | ||
writing: debug/nodes/1/ranges/3.json | ||
|
@@ -98,6 +98,7 @@ writing: debug/nodes/1/ranges/33.json | |
writing: debug/nodes/1/ranges/34.json | ||
writing: debug/nodes/1/ranges/35.json | ||
writing: debug/nodes/1/ranges/36.json | ||
writing: debug/nodes/1/ranges/37.json | ||
writing: debug/nodes/2/status.json | ||
using SQL connection URL for node 2: postgresql://... | ||
retrieving SQL data for crdb_internal.feature_usage... writing: debug/nodes/2/crdb_internal.feature_usage.txt | ||
|
@@ -202,7 +203,7 @@ requesting goroutine files for node 3... writing: debug/nodes/3/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 36 found | ||
requesting ranges... 37 found | ||
writing: debug/nodes/3/ranges/1.json | ||
writing: debug/nodes/3/ranges/2.json | ||
writing: debug/nodes/3/ranges/3.json | ||
|
@@ -239,14 +240,15 @@ writing: debug/nodes/3/ranges/33.json | |
writing: debug/nodes/3/ranges/34.json | ||
writing: debug/nodes/3/ranges/35.json | ||
writing: debug/nodes/3/ranges/36.json | ||
writing: debug/nodes/3/ranges/37.json | ||
doctor examining cluster...writing: debug/reports/doctor.txt | ||
requesting list of SQL databases... 3 found | ||
requesting database details for defaultdb... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
30 tables found | ||
31 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system/public_users.json | ||
|
@@ -277,5 +279,6 @@ requesting table details for system.public.statement_diagnostics... writing: deb | |
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system/public_migrations.json | ||
requesting table details for system.public.join_tokens... writing: debug/schema/system/public_join_tokens.json | ||
writing: debug/pprof-summary.sh | ||
writing: debug/hot-ranges.sh |
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 |
---|---|---|
|
@@ -61,7 +61,7 @@ requesting goroutine files for node 1... writing: debug/nodes/1/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 36 found | ||
requesting ranges... 37 found | ||
writing: debug/nodes/1/ranges/1.json | ||
writing: debug/nodes/1/ranges/2.json | ||
writing: debug/nodes/1/ranges/3.json | ||
|
@@ -98,6 +98,7 @@ writing: debug/nodes/1/ranges/33.json | |
writing: debug/nodes/1/ranges/34.json | ||
writing: debug/nodes/1/ranges/35.json | ||
writing: debug/nodes/1/ranges/36.json | ||
writing: debug/nodes/1/ranges/37.json | ||
writing: debug/nodes/2.skipped | ||
writing: debug/nodes/3/status.json | ||
using SQL connection URL for node 3: postgresql://... | ||
|
@@ -130,7 +131,7 @@ requesting goroutine files for node 3... writing: debug/nodes/3/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 36 found | ||
requesting ranges... 37 found | ||
writing: debug/nodes/3/ranges/1.json | ||
writing: debug/nodes/3/ranges/2.json | ||
writing: debug/nodes/3/ranges/3.json | ||
|
@@ -167,14 +168,15 @@ writing: debug/nodes/3/ranges/33.json | |
writing: debug/nodes/3/ranges/34.json | ||
writing: debug/nodes/3/ranges/35.json | ||
writing: debug/nodes/3/ranges/36.json | ||
writing: debug/nodes/3/ranges/37.json | ||
doctor examining cluster...writing: debug/reports/doctor.txt | ||
requesting list of SQL databases... 3 found | ||
requesting database details for defaultdb... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
30 tables found | ||
31 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system/public_users.json | ||
|
@@ -205,5 +207,6 @@ requesting table details for system.public.statement_diagnostics... writing: deb | |
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system/public_migrations.json | ||
requesting table details for system.public.join_tokens... writing: debug/schema/system/public_join_tokens.json | ||
writing: debug/pprof-summary.sh | ||
writing: debug/hot-ranges.sh |
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 |
---|---|---|
|
@@ -61,7 +61,7 @@ requesting goroutine files for node 1... writing: debug/nodes/1/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 36 found | ||
requesting ranges... 37 found | ||
writing: debug/nodes/1/ranges/1.json | ||
writing: debug/nodes/1/ranges/2.json | ||
writing: debug/nodes/1/ranges/3.json | ||
|
@@ -98,6 +98,7 @@ writing: debug/nodes/1/ranges/33.json | |
writing: debug/nodes/1/ranges/34.json | ||
writing: debug/nodes/1/ranges/35.json | ||
writing: debug/nodes/1/ranges/36.json | ||
writing: debug/nodes/1/ranges/37.json | ||
writing: debug/nodes/3/status.json | ||
using SQL connection URL for node 3: postgresql://... | ||
retrieving SQL data for crdb_internal.feature_usage... writing: debug/nodes/3/crdb_internal.feature_usage.txt | ||
|
@@ -129,7 +130,7 @@ requesting goroutine files for node 3... writing: debug/nodes/3/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 36 found | ||
requesting ranges... 37 found | ||
writing: debug/nodes/3/ranges/1.json | ||
writing: debug/nodes/3/ranges/2.json | ||
writing: debug/nodes/3/ranges/3.json | ||
|
@@ -166,14 +167,15 @@ writing: debug/nodes/3/ranges/33.json | |
writing: debug/nodes/3/ranges/34.json | ||
writing: debug/nodes/3/ranges/35.json | ||
writing: debug/nodes/3/ranges/36.json | ||
writing: debug/nodes/3/ranges/37.json | ||
doctor examining cluster...writing: debug/reports/doctor.txt | ||
requesting list of SQL databases... 3 found | ||
requesting database details for defaultdb... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
30 tables found | ||
31 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system/public_users.json | ||
|
@@ -204,5 +206,6 @@ requesting table details for system.public.statement_diagnostics... writing: deb | |
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system/public_migrations.json | ||
requesting table details for system.public.join_tokens... writing: debug/schema/system/public_join_tokens.json | ||
writing: debug/pprof-summary.sh | ||
writing: debug/hot-ranges.sh |
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 |
---|---|---|
|
@@ -22,7 +22,7 @@ requesting table details for defaultdb.public."../system"... writing: debug/sche | |
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
30 tables found | ||
31 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system-1/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system-1/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system-1/public_users.json | ||
|
@@ -53,3 +53,4 @@ requesting table details for system.public.statement_diagnostics... writing: deb | |
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system-1/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system-1/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system-1/public_migrations.json | ||
requesting table details for system.public.join_tokens... writing: debug/schema/system-1/public_join_tokens.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 |
---|---|---|
|
@@ -60,7 +60,7 @@ requesting heap profile for node 1... writing: debug/nodes/1/heap.pprof | |
requesting heap files for node 1... ? found | ||
requesting goroutine files for node 1... 0 found | ||
requesting log file ... | ||
requesting ranges... 36 found | ||
requesting ranges... 37 found | ||
writing: debug/nodes/1/ranges/1.json | ||
writing: debug/nodes/1/ranges/2.json | ||
writing: debug/nodes/1/ranges/3.json | ||
|
@@ -97,14 +97,15 @@ writing: debug/nodes/1/ranges/33.json | |
writing: debug/nodes/1/ranges/34.json | ||
writing: debug/nodes/1/ranges/35.json | ||
writing: debug/nodes/1/ranges/36.json | ||
writing: debug/nodes/1/ranges/37.json | ||
doctor examining cluster...writing: debug/reports/doctor.txt | ||
requesting list of SQL databases... 3 found | ||
requesting database details for defaultdb... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
30 tables found | ||
31 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system/public_users.json | ||
|
@@ -135,5 +136,6 @@ requesting table details for system.public.statement_diagnostics... writing: deb | |
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system/public_migrations.json | ||
requesting table details for system.public.join_tokens... writing: debug/schema/system/public_join_tokens.json | ||
writing: debug/pprof-summary.sh | ||
writing: debug/hot-ranges.sh |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package migrations | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/clusterversion" | ||
"github.com/cockroachdb/cockroach/pkg/migration" | ||
"github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" | ||
"github.com/cockroachdb/cockroach/pkg/sqlmigrations" | ||
) | ||
|
||
func joinTokensTableMigration( | ||
ctx context.Context, _ clusterversion.ClusterVersion, d migration.SQLDeps, | ||
) error { | ||
return sqlmigrations.CreateSystemTable( | ||
ctx, d.DB, d.Codec, d.Settings, systemschema.JoinTokensTable, | ||
) | ||
} |
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.