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/schemachanger: add back TXN_DROPPED, stop using OFFLINE #86639

Merged
merged 6 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pkg/bench/rttanalysis/testdata/benchmark_expectations
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ exp,benchmark
16,CreateRole/create_role_with_2_options
19,CreateRole/create_role_with_3_options
14,CreateRole/create_role_with_no_options
15,DropDatabase/drop_database_0_tables
17,DropDatabase/drop_database_1_table
19,DropDatabase/drop_database_2_tables
21,DropDatabase/drop_database_3_tables
13,DropDatabase/drop_database_0_tables
15,DropDatabase/drop_database_1_table
17,DropDatabase/drop_database_2_tables
19,DropDatabase/drop_database_3_tables
19,DropRole/drop_1_role
27,DropRole/drop_2_roles
35,DropRole/drop_3_roles
17,DropSequence/drop_1_sequence
19,DropSequence/drop_2_sequences
21,DropSequence/drop_3_sequences
18,DropTable/drop_1_table
21,DropTable/drop_2_tables
24,DropTable/drop_3_tables
19,DropView/drop_1_view
20,DropView/drop_2_views
20,DropView/drop_3_views
15,DropSequence/drop_1_sequence
17,DropSequence/drop_2_sequences
19,DropSequence/drop_3_sequences
16,DropTable/drop_1_table
19,DropTable/drop_2_tables
22,DropTable/drop_3_tables
17,DropView/drop_1_view
18,DropView/drop_2_views
18,DropView/drop_3_views
13,Grant/grant_all_on_1_table
14,Grant/grant_all_on_2_tables
14,Grant/grant_all_on_3_tables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@ DROP DATABASE dd CASCADE;
----
job paused at pausepoint

# At this point, we have a descriptor entry for `dd` in an OFFLINE state.
# At this point, we have a descriptor entry for `dd` in a dropped 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;
----
"dd" "OFFLINE"
"dd" "DROP"

# A database backup should fail since we are explicitly targeting an offline
# A database backup should fail since we are explicitly targeting a dropped
# object.
exec-sql
BACKUP DATABASE dd INTO 'nodelocal://0/dropped-database';
----
pq: failed to resolve targets specified in the BACKUP stmt: database "dd" does not exist
pq: failed to resolve targets specified in the BACKUP stmt: database "dd" does not exist, or invalid RESTORE timestamp: supplied backups do not cover requested time

# A cluster backup should succeed.
exec-sql
BACKUP INTO 'nodelocal://0/cluster/dropped-database';
----

# The offline descriptors should end up in the cluster backup.
# The dropped descriptors should not end up in the cluster backup.
query-sql
SELECT count(*)
FROM [SHOW BACKUP LATEST IN 'nodelocal://0/cluster/dropped-database']
WHERE object_name IN ('dd', 'foo', 's');
----
3
0

subtest end

Expand Down Expand Up @@ -99,18 +99,18 @@ WITH tbls AS (
)
SELECT orig->'schema'->'name', orig->'schema'->'state' FROM tbls WHERE id = 112;
----
"s" "OFFLINE"
"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" "OFFLINE"
"_typ" "OFFLINE"
"typ" "DROP"
"_typ" "DROP"

# A database backup should succeed and should include the offline schema,
# A database backup should succeed and should not include the dropped schema,
# type, and table.
exec-sql
BACKUP DATABASE d2 INTO 'nodelocal://0/dropped-schema-in-database';
Expand All @@ -121,9 +121,9 @@ SELECT count(*)
FROM [SHOW BACKUP LATEST IN 'nodelocal://0/dropped-schema-in-database']
WHERE object_name IN ('s', 't', 'typ', '_typ');
----
4
0

# A cluster backup should succeed but should include the offline schema,
# 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';
Expand All @@ -134,7 +134,7 @@ SELECT count(*)
FROM [SHOW BACKUP LATEST IN 'nodelocal://0/cluster/dropped-schema-in-database']
WHERE object_name IN ('s', 't', 'typ', '_typ');
----
4
0

# Restore the backups to check they are valid.
exec-sql
Expand All @@ -145,12 +145,11 @@ exec-sql
USE d3;
----

# We expect to see the offline schema 's'.
# We expect to not see the dropped schema 's'.
query-sql
SELECT schema_name FROM [SHOW SCHEMAS];
----
public
s
crdb_internal
information_schema
pg_catalog
Expand All @@ -161,7 +160,6 @@ query-sql
SELECT schema_name, table_name FROM [SHOW TABLES];
----
public t2
s t

exec-sql
RESTORE DATABASE d2 FROM LATEST IN 'nodelocal://0/cluster/dropped-schema-in-database' WITH new_db_name ='d4';
Expand All @@ -175,7 +173,6 @@ query-sql
SELECT schema_name FROM [SHOW SCHEMAS];
----
public
s
crdb_internal
information_schema
pg_catalog
Expand All @@ -185,6 +182,5 @@ query-sql
SELECT schema_name, table_name FROM [SHOW TABLES];
----
public t2
s t

subtest end
8 changes: 0 additions & 8 deletions pkg/ccl/schemachangerccl/testdata/end_to_end/create_index
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ upsert descriptor #104
+ targets: <redacted>
families:
- columnIds:
...
formatVersion: 3
id: 104
- modificationTime: {}
+ modificationTime:
+ wallTime: "1640995200000000001"
mutations:
- direction: ADD
...
create job #1 (non-cancelable: false): "CREATE INDEX id1 ON defaultdb.public.t1 (id, name) STORING (money) PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1))"
descriptor IDs: [104]
Expand Down
Loading