-
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.
75660: sql,security: gate session revival behind a cluster setting r=JeffSwenson,otan a=rafiss fixes #74643 Stop allowing any multitenant cluster from using this functionality. Release note (security update): The cluster setting server.user_login.session_revival_token.enabled has been added. It is false by default. If it is set to true, then a new token-based authentication mechanism is enabled. A token can be generated using the crdb_internal.create_session_revival_token builtin function. The token has a lifetime of 10 minutes and is cryptographically signed to prevent spoofing and brute-forcing attempts. When initializing a session later, the token can be presented in a pgwire StartupMessage with a parameter name of `crdb:session_revival_token_base64`, with the value encoded in base64. If this parameter is present, all other authentication checks are disabled, and if the token is valid and has a valid signature, the user who originally generated the token authenticates into a new SQL session. If the token is not valid, then authentication fails. The token does not have "use-once" semantics, so the same token can be used any number of times to create multiple new SQL sessions within the 10 minute lifetime of the token. As such, the token should be treated as highly sensitive cryptographic information. This feature is meant to be used by multitenant deployments to move a SQL session from one node to another. It requires the presence of a valid Ed25519 keypair in tenant-signing.<tenant_id>.crt and tenant-signing.<tenant_id>.key. 76635: backupccl: ignore all dropped descriptors during backup r=ajwerner,stevendanna a=adityamaru Previously, descriptors that were resolved at `EndTime` and were in a `DROP` state were not treated uniformly. While we ignored table descriptors, we continued to backup database, schema and type descrpitors. This resulted in atleast two bugs: 1) If a database descriptor was in a dropped state, and a new descriptor with the same name was created then a BACKUP DATABASE of the new database would fail during resolution. 2) A cluster backup of the above state would succeed, but since it would include duplicate entries for the same name database, the restore of such a backup would fail. This change unifies the behaviour by ignoring all DROP descriptors seen by the backup at `EndTime`. A follow up PR will teach restore to ignore all dropped descriptors so as to allow users with "corrupt" backups as explained in 2) to be able to restore. Informs: #76517 Release note (bug fix): Backup incorrectly backed up database, schema, and type descriptors that were in a DROP state at the time the backup was run. This bug resulted in the user being unable to backup and restore if their cluster had dropped and public descriptors with colliding names. 76691: ui: Remove "reset time" n Statements and Transactions Pages r=jocrl a=jocrl Addresses #70997 This commit removes the "reset time" link on Statements and Transactions Pages. Release note (ui): The "Now" button had been added in this commit jocrl@82f2673 to the Statements and Transactions Pages. This commit removes the "reset time" link which the "Now" button replaces. Before, Statements Page: <img width="1356" alt="image" src="https://user-images.githubusercontent.com/91907326/154362540-4268376e-9e4e-4ed2-9f0e-86727ce0ce23.png"> After, Statements Page: <img width="1264" alt="image" src="https://user-images.githubusercontent.com/91907326/154362398-ac1cd126-a5bc-4268-aad5-823e82327271.png"> Before, Transactions Page: <img width="1395" alt="image" src="https://user-images.githubusercontent.com/91907326/154362513-c107240f-f8c3-44ad-95d3-ca0f54db8a48.png"> After, Transactions Page: <img width="1272" alt="image" src="https://user-images.githubusercontent.com/91907326/154362438-33911b3b-cd23-428d-97af-b2fbf69acb94.png"> Co-authored-by: Rafi Shamim <[email protected]> Co-authored-by: Aditya Maru <[email protected]> Co-authored-by: Josephine Lee <[email protected]>
- Loading branch information
Showing
15 changed files
with
271 additions
and
47 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
200 changes: 200 additions & 0 deletions
200
pkg/ccl/backupccl/testdata/backup-restore/backup-dropped-descriptors
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,200 @@ | ||
# backup-dropped-desctiprors tests backup and restore interaction with database, schema | ||
# and type descriptors in the DROP state. | ||
subtest dropped-database-descriptors | ||
|
||
new-server name=s1 | ||
---- | ||
|
||
exec-sql | ||
SET CLUSTER SETTING jobs.debug.pausepoints = 'schemachanger.before.exec'; | ||
CREATE DATABASE d; | ||
CREATE TABLE d.foo (id INT); | ||
DROP DATABASE d CASCADE; | ||
---- | ||
paused before it completed with reason: pause point "schemachanger.before.exec" hit | ||
|
||
# At this point, we have a descriptor entry for `d` in a DROP state. | ||
query-sql | ||
WITH tbls AS ( | ||
SELECT id, crdb_internal.pb_to_json('cockroach.sql.sqlbase.Descriptor', descriptor) AS orig FROM system.descriptor | ||
) | ||
SELECT orig->'database'->'name', orig->'database'->'state' FROM tbls WHERE id = 107; | ||
---- | ||
"d" "DROP" | ||
|
||
# A database backup should fail since we are explicitly targeting a dropped | ||
# object. | ||
exec-sql | ||
BACKUP DATABASE d INTO 'nodelocal://0/dropped-database'; | ||
---- | ||
pq: failed to resolve targets specified in the BACKUP stmt: database "d" does not exist, or invalid RESTORE timestamp: supplied backups do not cover requested time | ||
|
||
# A cluster backup should succeed but should ignore the dropped database | ||
# and table descriptors. | ||
exec-sql | ||
BACKUP INTO 'nodelocal://0/cluster/dropped-database'; | ||
---- | ||
|
||
query-sql | ||
SELECT count(*) FROM [SHOW BACKUP LATEST IN 'nodelocal://0/cluster/dropped-database'] WHERE object_name = 'd' OR object_name = 'foo'; | ||
---- | ||
0 | ||
|
||
# Now create another descriptor entry with the same name in a PUBLIC state. | ||
exec-sql | ||
CREATE DATABASE d; | ||
CREATE TABLE d.bar (id INT); | ||
---- | ||
|
||
# A database backup should succeed since we have a public database descriptor that matches the | ||
# target. | ||
exec-sql | ||
BACKUP DATABASE d INTO 'nodelocal://0/dropped-database'; | ||
---- | ||
|
||
# A cluster backup should succeed and include the public database descriptor and | ||
# its table. | ||
exec-sql | ||
BACKUP INTO 'nodelocal://0/cluster/dropped-database'; | ||
---- | ||
|
||
# Restore from the database backup to ensure it is valid. | ||
# Sanity check that we did not backup the table 'foo' that belonged to the | ||
# dropped database 'd'. | ||
exec-sql | ||
RESTORE DATABASE d FROM LATEST IN 'nodelocal://0/dropped-database' WITH new_db_name = 'd1'; | ||
USE d1; | ||
---- | ||
|
||
query-sql | ||
SELECT schema_name,table_name FROM [SHOW TABLES]; | ||
---- | ||
public bar | ||
|
||
# Restore from the cluster backup to ensure it is valid. | ||
# Sanity check that we did not backup the table 'foo' that belonged to the | ||
# dropped database 'd'. | ||
exec-sql | ||
RESTORE DATABASE d FROM LATEST IN 'nodelocal://0/cluster/dropped-database' WITH new_db_name = 'd2'; | ||
USE d2; | ||
---- | ||
|
||
query-sql | ||
SELECT schema_name,table_name FROM [SHOW TABLES]; | ||
---- | ||
public bar | ||
|
||
subtest end | ||
|
||
# Test backup/restore interaction with dropped schema and type in a database. | ||
subtest dropped-schema-descriptors | ||
|
||
new-server name=s2 | ||
---- | ||
|
||
exec-sql | ||
CREATE DATABASE d2; | ||
CREATE TABLE d2.t2 (id INT); | ||
---- | ||
|
||
exec-sql | ||
CREATE TYPE d2.typ AS ENUM ('hello'); | ||
CREATE SCHEMA d2.s; | ||
CREATE TABLE d2.s.t (id INT); | ||
SET CLUSTER SETTING jobs.debug.pausepoints = 'schemachanger.before.exec'; | ||
DROP SCHEMA d2.s CASCADE; | ||
---- | ||
paused before it completed with reason: pause point "schemachanger.before.exec" hit | ||
|
||
exec-sql | ||
SET CLUSTER SETTING jobs.debug.pausepoints = 'typeschemachanger.before.exec'; | ||
DROP TYPE d2.typ; | ||
---- | ||
paused before it completed with reason: pause point "typeschemachanger.before.exec" hit | ||
|
||
query-sql | ||
WITH tbls AS ( | ||
SELECT id, crdb_internal.pb_to_json('cockroach.sql.sqlbase.Descriptor', descriptor) AS orig FROM system.descriptor | ||
) | ||
SELECT orig->'schema'->'name', orig->'schema'->'state' FROM tbls WHERE id = 112; | ||
---- | ||
"s" "DROP" | ||
|
||
|
||
query-sql | ||
WITH tbls AS ( | ||
SELECT id, crdb_internal.pb_to_json('cockroach.sql.sqlbase.Descriptor', descriptor) AS orig FROM system.descriptor | ||
) | ||
SELECT orig->'type'->'name', orig->'type'->'state' FROM tbls WHERE id = 110 OR id = 111; | ||
---- | ||
"typ" "DROP" | ||
"_typ" "DROP" | ||
|
||
# A database backup should succeed but should not include the dropped schema, | ||
# type, and table. | ||
exec-sql | ||
BACKUP DATABASE d2 INTO 'nodelocal://0/dropped-schema-in-database'; | ||
---- | ||
|
||
query-sql | ||
SELECT count(*) FROM [SHOW BACKUP LATEST IN 'nodelocal://0/dropped-schema-in-database'] WHERE | ||
object_name = 's' OR object_name = 'typ'; | ||
---- | ||
0 | ||
|
||
|
||
# A cluster backup should succeed but should not include the dropped schema, | ||
# type, and table. | ||
exec-sql | ||
BACKUP INTO 'nodelocal://0/cluster/dropped-schema-in-database'; | ||
---- | ||
|
||
query-sql | ||
SELECT count(*) FROM [SHOW BACKUP LATEST IN 'nodelocal://0/cluster/dropped-schema-in-database'] | ||
WHERE object_name = 's' OR object_name = 'typ'; | ||
---- | ||
0 | ||
|
||
# Restore the backups to check they are valid. | ||
exec-sql | ||
RESTORE DATABASE d2 FROM LATEST IN 'nodelocal://0/dropped-schema-in-database' WITH new_db_name = 'd3'; | ||
USE d3; | ||
---- | ||
|
||
# We don't expect to see the dropped schema 's'. | ||
query-sql | ||
SELECT schema_name FROM [SHOW SCHEMAS]; | ||
---- | ||
public | ||
crdb_internal | ||
information_schema | ||
pg_catalog | ||
pg_extension | ||
|
||
|
||
query-sql | ||
SELECT schema_name, table_name FROM [SHOW TABLES]; | ||
---- | ||
public t2 | ||
|
||
|
||
exec-sql | ||
RESTORE DATABASE d2 FROM LATEST IN 'nodelocal://0/cluster/dropped-schema-in-database' WITH new_db_name ='d4'; | ||
USE d4; | ||
---- | ||
|
||
query-sql | ||
SELECT schema_name FROM [SHOW SCHEMAS]; | ||
---- | ||
public | ||
crdb_internal | ||
information_schema | ||
pg_catalog | ||
pg_extension | ||
|
||
query-sql | ||
SELECT schema_name, table_name FROM [SHOW TABLES]; | ||
---- | ||
public t2 | ||
|
||
subtest end |
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
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.