diff --git a/docs/generated/sql/bnf/BUILD.bazel b/docs/generated/sql/bnf/BUILD.bazel index 1753d9e74a8c..644cef523a04 100644 --- a/docs/generated/sql/bnf/BUILD.bazel +++ b/docs/generated/sql/bnf/BUILD.bazel @@ -8,6 +8,7 @@ FILES = [ "alter_backup", "alter_backup_schedule", "alter_column", + "alter_database", "alter_database_add_region_stmt", "alter_database_add_super_region", "alter_database_set_secondary_region_stmt", @@ -16,8 +17,10 @@ FILES = [ "alter_database_drop_region", "alter_database_drop_secondary_region", "alter_database_owner", + "alter_database_placement_stmt", "alter_database_primary_region", "alter_database_set_zone_config_extension_stmt", + "alter_database_set_stmt", "alter_database_stmt", "alter_database_survival_goal_stmt", "alter_database_to_schema_stmt", @@ -30,11 +33,13 @@ FILES = [ "alter_func_set_schema_stmt", "alter_func_dep_extension_stmt", "alter_index_partition_by", + "alter_index", "alter_index_stmt", "alter_index_visible_stmt", "alter_partition_stmt", "alter_primary_key", "alter_range_relocate_stmt", + "alter_range", "alter_range_stmt", "alter_rename_view_stmt", "alter_role_stmt", @@ -47,6 +52,7 @@ FILES = [ "alter_sequence_set_schema_stmt", "alter_stmt", "alter_table", + "alter_table_cmds", "alter_table_locality_stmt", "alter_table_owner_stmt", "alter_table_partition_by", diff --git a/docs/generated/sql/bnf/alter_database.bnf b/docs/generated/sql/bnf/alter_database.bnf new file mode 100644 index 000000000000..0cbad4e4722b --- /dev/null +++ b/docs/generated/sql/bnf/alter_database.bnf @@ -0,0 +1,41 @@ +alter_database_stmt ::= + 'ALTER' 'DATABASE' database_name 'RENAME' 'TO' database_new_name + | 'ALTER' 'DATABASE' database_name 'CONFIGURE' 'ZONE' 'USING' variable '=' 'COPY' 'FROM' 'PARENT' ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'DATABASE' database_name 'CONFIGURE' 'ZONE' 'USING' variable '=' value ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'DATABASE' database_name 'CONFIGURE' 'ZONE' 'DISCARD' + | 'ALTER' 'DATABASE' database_name 'OWNER' 'TO' role_spec + | 'ALTER' 'DATABASE' database_name 'CONVERT' 'TO' 'SCHEMA' 'WITH' 'PARENT' database_name + | 'ALTER' 'DATABASE' database_name 'ADD' 'REGION' region_name + | 'ALTER' 'DATABASE' database_name 'ADD' 'REGION' 'IF' 'NOT' 'EXISTS' region_name + | 'ALTER' 'DATABASE' database_name 'DROP' 'REGION' region_name + | 'ALTER' 'DATABASE' database_name 'DROP' 'REGION' 'IF' 'EXISTS' region_name + | 'ALTER' 'DATABASE' database_name 'SURVIVE' '=' 'REGION' 'FAILURE' + | 'ALTER' 'DATABASE' database_name 'SURVIVE' 'REGION' 'FAILURE' + | 'ALTER' 'DATABASE' database_name 'SURVIVE' '=' 'ZONE' 'FAILURE' + | 'ALTER' 'DATABASE' database_name 'SURVIVE' 'ZONE' 'FAILURE' + | 'ALTER' 'DATABASE' database_name 'PRIMARY' 'REGION' '=' region_name + | 'ALTER' 'DATABASE' database_name 'PRIMARY' 'REGION' region_name + | 'ALTER' 'DATABASE' database_name 'SET' 'PRIMARY' 'REGION' '=' region_name + | 'ALTER' 'DATABASE' database_name 'SET' 'PRIMARY' 'REGION' region_name + | 'ALTER' 'DATABASE' database_name 'PLACEMENT' 'RESTRICTED' + | 'ALTER' 'DATABASE' database_name 'PLACEMENT' 'DEFAULT' + | 'ALTER' 'DATABASE' database_name 'SET' variable '=' value ( ( ',' value ) )* + | 'ALTER' 'DATABASE' database_name 'SET' variable 'TO' value ( ( ',' value ) )* + | 'ALTER' 'DATABASE' database_name 'RESET_ALL' 'ALL' + | 'ALTER' 'DATABASE' database_name 'RESET' session_var + | 'ALTER' 'DATABASE' database_name 'ADD' 'SUPER' 'REGION' region_name 'VALUES' region_name_list + | 'ALTER' 'DATABASE' database_name 'ALTER' 'SUPER' 'REGION' region_name 'VALUES' region_name_list + | 'ALTER' 'DATABASE' database_name 'DROP' 'SUPER' 'REGION' region_name + | 'ALTER' 'DATABASE' database_name 'SET' 'SECONDARY' 'REGION' '=' region_name + | 'ALTER' 'DATABASE' database_name 'SET' 'SECONDARY' 'REGION' region_name + | 'ALTER' 'DATABASE' database_name 'DROP' 'SECONDARY' 'REGION' + | 'ALTER' 'DATABASE' database_name 'DROP' 'SECONDARY' 'REGION' 'IF' 'EXISTS' + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'GLOBAL' 'CONFIGURE' 'ZONE' 'USING' variable '=' 'COPY' 'FROM' 'PARENT' ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'GLOBAL' 'CONFIGURE' 'ZONE' 'USING' variable '=' value ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'GLOBAL' 'CONFIGURE' 'ZONE' 'DISCARD' + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'REGIONAL' 'CONFIGURE' 'ZONE' 'USING' variable '=' 'COPY' 'FROM' 'PARENT' ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'REGIONAL' 'CONFIGURE' 'ZONE' 'USING' variable '=' value ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'REGIONAL' 'CONFIGURE' 'ZONE' 'DISCARD' + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'REGIONAL' 'IN' region_name 'CONFIGURE' 'ZONE' 'USING' variable '=' 'COPY' 'FROM' 'PARENT' ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'REGIONAL' 'IN' region_name 'CONFIGURE' 'ZONE' 'USING' variable '=' value ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'DATABASE' database_name 'ALTER' 'LOCALITY' 'REGIONAL' 'IN' region_name 'CONFIGURE' 'ZONE' 'DISCARD' diff --git a/docs/generated/sql/bnf/alter_database_placement_stmt.bnf b/docs/generated/sql/bnf/alter_database_placement_stmt.bnf new file mode 100644 index 000000000000..1758e89ccb7c --- /dev/null +++ b/docs/generated/sql/bnf/alter_database_placement_stmt.bnf @@ -0,0 +1,2 @@ +alter_database_placement_stmt ::= + 'ALTER' 'DATABASE' database_name placement_clause diff --git a/docs/generated/sql/bnf/alter_database_set_stmt.bnf b/docs/generated/sql/bnf/alter_database_set_stmt.bnf new file mode 100644 index 000000000000..58e972cc65d4 --- /dev/null +++ b/docs/generated/sql/bnf/alter_database_set_stmt.bnf @@ -0,0 +1,2 @@ +alter_database_set_stmt ::= + 'ALTER' 'DATABASE' database_name set_or_reset_clause diff --git a/docs/generated/sql/bnf/alter_database_stmt.bnf b/docs/generated/sql/bnf/alter_database_stmt.bnf index 2420dccd7e76..d71b379d8860 100644 --- a/docs/generated/sql/bnf/alter_database_stmt.bnf +++ b/docs/generated/sql/bnf/alter_database_stmt.bnf @@ -7,6 +7,8 @@ alter_database_stmt ::= | alter_database_drop_region_stmt | alter_database_survival_goal_stmt | alter_database_primary_region_stmt + | alter_database_placement_stmt + | alter_database_set_stmt | alter_database_add_super_region | alter_database_alter_super_region | alter_database_drop_super_region diff --git a/docs/generated/sql/bnf/alter_func_stmt.bnf b/docs/generated/sql/bnf/alter_func_stmt.bnf index ade507d19839..3620edcf23c6 100644 --- a/docs/generated/sql/bnf/alter_func_stmt.bnf +++ b/docs/generated/sql/bnf/alter_func_stmt.bnf @@ -1,6 +1,6 @@ alter_func_stmt ::= ( 'ALTER' 'FUNCTION' function_with_paramtypes ( ( ( 'CALLED' 'ON' 'NULL' 'INPUT' | 'RETURNS' 'NULL' 'ON' 'NULL' 'INPUT' | 'STRICT' | 'IMMUTABLE' | 'STABLE' | 'VOLATILE' | 'LEAKPROOF' | 'NOT' 'LEAKPROOF' ) ) ( ( ( 'CALLED' 'ON' 'NULL' 'INPUT' | 'RETURNS' 'NULL' 'ON' 'NULL' 'INPUT' | 'STRICT' | 'IMMUTABLE' | 'STABLE' | 'VOLATILE' | 'LEAKPROOF' | 'NOT' 'LEAKPROOF' ) ) )* ) ( 'RESTRICT' | ) ) - | ( 'ALTER' 'FUNCTION' function_with_paramtypes 'RENAME' 'TO' name ) + | ( 'ALTER' 'FUNCTION' function_with_paramtypes 'RENAME' 'TO' function_new_name ) | ( 'ALTER' 'FUNCTION' function_with_paramtypes 'OWNER' 'TO' role_spec ) | ( 'ALTER' 'FUNCTION' function_with_paramtypes 'SET' 'SCHEMA' schema_name ) | ( 'ALTER' 'FUNCTION' function_with_paramtypes ( 'NO' | ) 'DEPENDS' 'ON' 'EXTENSION' name ) diff --git a/docs/generated/sql/bnf/alter_index.bnf b/docs/generated/sql/bnf/alter_index.bnf new file mode 100644 index 000000000000..ca8ff21d2e4f --- /dev/null +++ b/docs/generated/sql/bnf/alter_index.bnf @@ -0,0 +1,43 @@ +alter_index_stmt ::= + 'ALTER' 'INDEX' table_name '@' index_name 'PARTITION' 'BY' 'LIST' '(' name_list ')' '(' list_partitions ')' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' table_name '@' index_name 'PARTITION' 'BY' 'RANGE' '(' name_list ')' '(' range_partitions ')' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' table_name '@' index_name 'PARTITION' 'BY' 'NOTHING' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' index_name 'PARTITION' 'BY' 'LIST' '(' name_list ')' '(' list_partitions ')' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' index_name 'PARTITION' 'BY' 'RANGE' '(' name_list ')' '(' range_partitions ')' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' index_name 'PARTITION' 'BY' 'NOTHING' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' 'IF' 'EXISTS' table_name '@' index_name 'PARTITION' 'BY' 'LIST' '(' name_list ')' '(' list_partitions ')' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' 'IF' 'EXISTS' table_name '@' index_name 'PARTITION' 'BY' 'RANGE' '(' name_list ')' '(' range_partitions ')' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' 'IF' 'EXISTS' table_name '@' index_name 'PARTITION' 'BY' 'NOTHING' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' 'IF' 'EXISTS' index_name 'PARTITION' 'BY' 'LIST' '(' name_list ')' '(' list_partitions ')' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' 'IF' 'EXISTS' index_name 'PARTITION' 'BY' 'RANGE' '(' name_list ')' '(' range_partitions ')' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' 'IF' 'EXISTS' index_name 'PARTITION' 'BY' 'NOTHING' ( ( ',' ( ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) ) ) ) )* + | 'ALTER' 'INDEX' table_name '@' index_name 'SPLIT' 'AT' select_stmt + | 'ALTER' 'INDEX' index_name 'SPLIT' 'AT' select_stmt + | 'ALTER' 'INDEX' table_name '@' index_name 'SPLIT' 'AT' select_stmt 'WITH' 'EXPIRATION' a_expr + | 'ALTER' 'INDEX' index_name 'SPLIT' 'AT' select_stmt 'WITH' 'EXPIRATION' a_expr + | 'ALTER' 'INDEX' table_name '@' index_name 'UNSPLIT' 'AT' select_stmt + | 'ALTER' 'INDEX' index_name 'UNSPLIT' 'AT' select_stmt + | 'ALTER' 'INDEX' table_name '@' index_name 'UNSPLIT' 'ALL' + | 'ALTER' 'INDEX' index_name 'UNSPLIT' 'ALL' + | 'ALTER' 'INDEX' table_name '@' index_name 'RENAME' 'TO' index_new_name + | 'ALTER' 'INDEX' index_name 'RENAME' 'TO' index_new_name + | 'ALTER' 'INDEX' 'IF' 'EXISTS' table_name '@' index_name 'RENAME' 'TO' index_new_name + | 'ALTER' 'INDEX' 'IF' 'EXISTS' index_name 'RENAME' 'TO' index_new_name + | 'ALTER' 'INDEX' table_name '@' index_name 'CONFIGURE' 'ZONE' 'USING' variable '=' 'COPY' 'FROM' 'PARENT' ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'INDEX' table_name '@' index_name 'CONFIGURE' 'ZONE' 'USING' variable '=' value ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'INDEX' table_name '@' index_name 'CONFIGURE' 'ZONE' 'DISCARD' + | 'ALTER' 'INDEX' index_name 'CONFIGURE' 'ZONE' 'USING' variable '=' 'COPY' 'FROM' 'PARENT' ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'INDEX' index_name 'CONFIGURE' 'ZONE' 'USING' variable '=' value ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'INDEX' index_name 'CONFIGURE' 'ZONE' 'DISCARD' + | 'ALTER' 'INDEX' table_name '@' index_name 'NOT' 'VISIBLE' + | 'ALTER' 'INDEX' table_name '@' index_name 'INVISIBLE' + | 'ALTER' 'INDEX' table_name '@' index_name 'VISIBLE' + | 'ALTER' 'INDEX' index_name 'NOT' 'VISIBLE' + | 'ALTER' 'INDEX' index_name 'INVISIBLE' + | 'ALTER' 'INDEX' index_name 'VISIBLE' + | 'ALTER' 'INDEX' 'IF' 'EXISTS' table_name '@' index_name 'NOT' 'VISIBLE' + | 'ALTER' 'INDEX' 'IF' 'EXISTS' table_name '@' index_name 'INVISIBLE' + | 'ALTER' 'INDEX' 'IF' 'EXISTS' table_name '@' index_name 'VISIBLE' + | 'ALTER' 'INDEX' 'IF' 'EXISTS' index_name 'NOT' 'VISIBLE' + | 'ALTER' 'INDEX' 'IF' 'EXISTS' index_name 'INVISIBLE' + | 'ALTER' 'INDEX' 'IF' 'EXISTS' index_name 'VISIBLE' diff --git a/docs/generated/sql/bnf/alter_range.bnf b/docs/generated/sql/bnf/alter_range.bnf new file mode 100644 index 000000000000..ceb62388d13a --- /dev/null +++ b/docs/generated/sql/bnf/alter_range.bnf @@ -0,0 +1,12 @@ +alter_range_stmt ::= + 'ALTER' 'RANGE' range_id 'CONFIGURE' 'ZONE' 'USING' var_name '=' 'COPY' 'FROM' 'PARENT' ( ( ',' var_name '=' var_value | ',' var_name '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'RANGE' range_id 'CONFIGURE' 'ZONE' 'USING' var_name '=' var_value ( ( ',' var_name '=' var_value | ',' var_name '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'RANGE' range_id 'CONFIGURE' 'ZONE' 'DISCARD' + | 'ALTER' 'RANGE' 'RELOCATE' 'LEASE' 'TO' a_expr 'FOR' select_stmt + | 'ALTER' 'RANGE' range_id 'RELOCATE' 'LEASE' 'TO' a_expr + | 'ALTER' 'RANGE' 'RELOCATE' 'VOTERS' 'FROM' a_expr 'TO' a_expr 'FOR' select_stmt + | 'ALTER' 'RANGE' 'RELOCATE' 'FROM' a_expr 'TO' a_expr 'FOR' select_stmt + | 'ALTER' 'RANGE' 'RELOCATE' 'NONVOTERS' 'FROM' a_expr 'TO' a_expr 'FOR' select_stmt + | 'ALTER' 'RANGE' range_id 'RELOCATE' 'VOTERS' 'FROM' a_expr 'TO' a_expr + | 'ALTER' 'RANGE' range_id 'RELOCATE' 'FROM' a_expr 'TO' a_expr + | 'ALTER' 'RANGE' range_id 'RELOCATE' 'NONVOTERS' 'FROM' a_expr 'TO' a_expr diff --git a/docs/generated/sql/bnf/alter_schema.bnf b/docs/generated/sql/bnf/alter_schema.bnf index 99a437a987e7..35bc68c4fda5 100644 --- a/docs/generated/sql/bnf/alter_schema.bnf +++ b/docs/generated/sql/bnf/alter_schema.bnf @@ -1,3 +1,3 @@ alter_schema_stmt ::= - 'ALTER' 'SCHEMA' ( name | name '.' name ) 'RENAME' 'TO' schema_name + 'ALTER' 'SCHEMA' ( name | name '.' name ) 'RENAME' 'TO' schema_new_name | 'ALTER' 'SCHEMA' ( name | name '.' name ) 'OWNER' 'TO' role_spec diff --git a/docs/generated/sql/bnf/alter_table.bnf b/docs/generated/sql/bnf/alter_table.bnf index 5c8196aa7b3d..3069a8a8a912 100644 --- a/docs/generated/sql/bnf/alter_table.bnf +++ b/docs/generated/sql/bnf/alter_table.bnf @@ -1,3 +1,18 @@ -alter_onetable_stmt ::= - 'ALTER' 'TABLE' table_name ( ( ( 'RENAME' ( 'COLUMN' | ) column_name 'TO' column_name | 'RENAME' 'CONSTRAINT' column_name 'TO' column_name | 'ADD' ( column_name typename col_qual_list ) | 'ADD' 'IF' 'NOT' 'EXISTS' ( column_name typename col_qual_list ) | 'ADD' 'COLUMN' ( column_name typename col_qual_list ) | 'ADD' 'COLUMN' 'IF' 'NOT' 'EXISTS' ( column_name typename col_qual_list ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DEFAULT' a_expr | 'DROP' 'DEFAULT' ) | 'ALTER' ( 'COLUMN' | ) column_name alter_column_on_update | 'ALTER' ( 'COLUMN' | ) column_name 'SET' ('NOT' | ) 'VISIBLE' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'NOT' 'NULL' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'STORED' | 'ALTER' ( 'COLUMN' | ) column_name 'SET' 'NOT' 'NULL' | 'DROP' ( 'COLUMN' | ) 'IF' 'EXISTS' column_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' ( 'COLUMN' | ) column_name ( 'CASCADE' | 'RESTRICT' | ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DATA' | ) 'TYPE' typename ( 'COLLATE' collation_name | ) ( 'USING' a_expr | ) | 'ADD' ( 'CONSTRAINT' constraint_name constraint_elem | constraint_elem ) | 'ADD' 'CONSTRAINT' 'IF' 'NOT' 'EXISTS' constraint_name constraint_elem | 'ALTER' 'PRIMARY' 'KEY' 'USING' 'COLUMNS' '(' index_params ')' opt_hash_sharded opt_with_storage_parameter_list | 'VALIDATE' 'CONSTRAINT' constraint_name | 'DROP' 'CONSTRAINT' 'IF' 'EXISTS' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' 'CONSTRAINT' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'EXPERIMENTAL_AUDIT' 'SET' audit_mode | partition_by_table | 'SET' '(' storage_parameter_list ')' | 'RESET' '(' storage_parameter_key_list ')' ) ) ( ( ',' ( 'RENAME' ( 'COLUMN' | ) column_name 'TO' column_name | 'RENAME' 'CONSTRAINT' column_name 'TO' column_name | 'ADD' ( column_name typename col_qual_list ) | 'ADD' 'IF' 'NOT' 'EXISTS' ( column_name typename col_qual_list ) | 'ADD' 'COLUMN' ( column_name typename col_qual_list ) | 'ADD' 'COLUMN' 'IF' 'NOT' 'EXISTS' ( column_name typename col_qual_list ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DEFAULT' a_expr | 'DROP' 'DEFAULT' ) | 'ALTER' ( 'COLUMN' | ) column_name alter_column_on_update | 'ALTER' ( 'COLUMN' | ) column_name 'SET' ('NOT' | ) 'VISIBLE' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'NOT' 'NULL' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'STORED' | 'ALTER' ( 'COLUMN' | ) column_name 'SET' 'NOT' 'NULL' | 'DROP' ( 'COLUMN' | ) 'IF' 'EXISTS' column_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' ( 'COLUMN' | ) column_name ( 'CASCADE' | 'RESTRICT' | ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DATA' | ) 'TYPE' typename ( 'COLLATE' collation_name | ) ( 'USING' a_expr | ) | 'ADD' ( 'CONSTRAINT' constraint_name constraint_elem | constraint_elem ) | 'ADD' 'CONSTRAINT' 'IF' 'NOT' 'EXISTS' constraint_name constraint_elem | 'ALTER' 'PRIMARY' 'KEY' 'USING' 'COLUMNS' '(' index_params ')' opt_hash_sharded opt_with_storage_parameter_list | 'VALIDATE' 'CONSTRAINT' constraint_name | 'DROP' 'CONSTRAINT' 'IF' 'EXISTS' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' 'CONSTRAINT' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'EXPERIMENTAL_AUDIT' 'SET' audit_mode | partition_by_table | 'SET' '(' storage_parameter_list ')' | 'RESET' '(' storage_parameter_key_list ')' ) ) )* ) - | 'ALTER' 'TABLE' 'IF' 'EXISTS' table_name ( ( ( 'RENAME' ( 'COLUMN' | ) column_name 'TO' column_name | 'RENAME' 'CONSTRAINT' column_name 'TO' column_name | 'ADD' ( column_name typename col_qual_list ) | 'ADD' 'IF' 'NOT' 'EXISTS' ( column_name typename col_qual_list ) | 'ADD' 'COLUMN' ( column_name typename col_qual_list ) | 'ADD' 'COLUMN' 'IF' 'NOT' 'EXISTS' ( column_name typename col_qual_list ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DEFAULT' a_expr | 'DROP' 'DEFAULT' ) | 'ALTER' ( 'COLUMN' | ) column_name alter_column_on_update | 'ALTER' ( 'COLUMN' | ) column_name 'SET' ('NOT' | ) 'VISIBLE' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'NOT' 'NULL' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'STORED' | 'ALTER' ( 'COLUMN' | ) column_name 'SET' 'NOT' 'NULL' | 'DROP' ( 'COLUMN' | ) 'IF' 'EXISTS' column_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' ( 'COLUMN' | ) column_name ( 'CASCADE' | 'RESTRICT' | ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DATA' | ) 'TYPE' typename ( 'COLLATE' collation_name | ) ( 'USING' a_expr | ) | 'ADD' ( 'CONSTRAINT' constraint_name constraint_elem | constraint_elem ) | 'ADD' 'CONSTRAINT' 'IF' 'NOT' 'EXISTS' constraint_name constraint_elem | 'ALTER' 'PRIMARY' 'KEY' 'USING' 'COLUMNS' '(' index_params ')' opt_hash_sharded opt_with_storage_parameter_list | 'VALIDATE' 'CONSTRAINT' constraint_name | 'DROP' 'CONSTRAINT' 'IF' 'EXISTS' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' 'CONSTRAINT' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'EXPERIMENTAL_AUDIT' 'SET' audit_mode | partition_by_table | 'SET' '(' storage_parameter_list ')' | 'RESET' '(' storage_parameter_key_list ')' ) ) ( ( ',' ( 'RENAME' ( 'COLUMN' | ) column_name 'TO' column_name | 'RENAME' 'CONSTRAINT' column_name 'TO' column_name | 'ADD' ( column_name typename col_qual_list ) | 'ADD' 'IF' 'NOT' 'EXISTS' ( column_name typename col_qual_list ) | 'ADD' 'COLUMN' ( column_name typename col_qual_list ) | 'ADD' 'COLUMN' 'IF' 'NOT' 'EXISTS' ( column_name typename col_qual_list ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DEFAULT' a_expr | 'DROP' 'DEFAULT' ) | 'ALTER' ( 'COLUMN' | ) column_name alter_column_on_update | 'ALTER' ( 'COLUMN' | ) column_name 'SET' ('NOT' | ) 'VISIBLE' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'NOT' 'NULL' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'STORED' | 'ALTER' ( 'COLUMN' | ) column_name 'SET' 'NOT' 'NULL' | 'DROP' ( 'COLUMN' | ) 'IF' 'EXISTS' column_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' ( 'COLUMN' | ) column_name ( 'CASCADE' | 'RESTRICT' | ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DATA' | ) 'TYPE' typename ( 'COLLATE' collation_name | ) ( 'USING' a_expr | ) | 'ADD' ( 'CONSTRAINT' constraint_name constraint_elem | constraint_elem ) | 'ADD' 'CONSTRAINT' 'IF' 'NOT' 'EXISTS' constraint_name constraint_elem | 'ALTER' 'PRIMARY' 'KEY' 'USING' 'COLUMNS' '(' index_params ')' opt_hash_sharded opt_with_storage_parameter_list | 'VALIDATE' 'CONSTRAINT' constraint_name | 'DROP' 'CONSTRAINT' 'IF' 'EXISTS' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' 'CONSTRAINT' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'EXPERIMENTAL_AUDIT' 'SET' audit_mode | partition_by_table | 'SET' '(' storage_parameter_list ')' | 'RESET' '(' storage_parameter_key_list ')' ) ) )* ) +alter_table_stmt ::= + 'ALTER' 'TABLE' table_name alter_table_cmd ( ( ',' alter_table_cmd ) )* + | 'ALTER' 'TABLE' 'IF' 'EXISTS' table_name alter_table_cmd ( ( ',' alter_table_cmd ) )* + | 'ALTER' 'TABLE' table_name 'SPLIT' 'AT' select_stmt + | 'ALTER' 'TABLE' table_name 'SPLIT' 'AT' select_stmt 'WITH' 'EXPIRATION' a_expr + | 'ALTER' 'TABLE' table_name 'UNSPLIT' 'AT' select_stmt + | 'ALTER' 'TABLE' table_name 'UNSPLIT' 'ALL' + | 'ALTER' 'TABLE' table_name 'CONFIGURE' 'ZONE' 'USING' variable '=' 'COPY' 'FROM' 'PARENT' ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'TABLE' table_name 'CONFIGURE' 'ZONE' 'USING' variable '=' value ( ( ',' variable '=' value | ',' variable '=' 'COPY' 'FROM' 'PARENT' ) )* + | 'ALTER' 'TABLE' table_name 'CONFIGURE' 'ZONE' 'DISCARD' + | 'ALTER' 'TABLE' table_name 'RENAME' 'TO' table_new_name + | 'ALTER' 'TABLE' 'IF' 'EXISTS' table_name 'RENAME' 'TO' table_new_name + | 'ALTER' 'TABLE' table_name 'SET' 'SCHEMA' schema_name + | 'ALTER' 'TABLE' 'IF' 'EXISTS' table_name 'SET' 'SCHEMA' schema_name + | 'ALTER' 'TABLE' table_name 'SET' locality + | 'ALTER' 'TABLE' 'IF' 'EXISTS' table_name 'SET' locality + | 'ALTER' 'TABLE' table_name 'OWNER' 'TO' role_spec + | 'ALTER' 'TABLE' 'IF' 'EXISTS' table_name 'OWNER' 'TO' role_spec diff --git a/docs/generated/sql/bnf/alter_table_cmds.bnf b/docs/generated/sql/bnf/alter_table_cmds.bnf new file mode 100644 index 000000000000..da7639b6ca8a --- /dev/null +++ b/docs/generated/sql/bnf/alter_table_cmds.bnf @@ -0,0 +1,2 @@ +alter_table_cmds ::= + ( ( 'RENAME' ( 'COLUMN' | ) column_name 'TO' column_new_name | 'RENAME' 'CONSTRAINT' constraint_name 'TO' constraint_new_name | 'ADD' ( column_name typename ( ( ) ( ( col_qualification ) )* ) ) | 'ADD' 'IF' 'NOT' 'EXISTS' ( column_name typename ( ( ) ( ( col_qualification ) )* ) ) | 'ADD' 'COLUMN' ( column_name typename ( ( ) ( ( col_qualification ) )* ) ) | 'ADD' 'COLUMN' 'IF' 'NOT' 'EXISTS' ( column_name typename ( ( ) ( ( col_qualification ) )* ) ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DEFAULT' a_expr | 'DROP' 'DEFAULT' ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'ON' 'UPDATE' b_expr | 'DROP' 'ON' 'UPDATE' ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'VISIBLE' | 'SET' 'NOT' 'VISIBLE' ) | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'NOT' 'NULL' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'STORED' | 'ALTER' ( 'COLUMN' | ) column_name 'SET' 'NOT' 'NULL' | 'DROP' ( 'COLUMN' | ) 'IF' 'EXISTS' column_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' ( 'COLUMN' | ) column_name ( 'CASCADE' | 'RESTRICT' | ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DATA' | ) 'TYPE' typename ( 'COLLATE' collation_name | ) ( 'USING' a_expr | ) | 'ADD' ( 'CONSTRAINT' constraint_name constraint_elem | constraint_elem ) ( 'NOT' 'VALID' | ) | 'ADD' 'CONSTRAINT' 'IF' 'NOT' 'EXISTS' constraint_name constraint_elem ( 'NOT' 'VALID' | ) | 'ALTER' 'PRIMARY' 'KEY' 'USING' 'COLUMNS' '(' index_params ')' ( 'USING' 'HASH' | ) ( 'WITH' '(' ( ( ( storage_parameter_key '=' value ) ) ( ( ',' ( storage_parameter_key '=' value ) ) )* ) ')' ) | 'VALIDATE' 'CONSTRAINT' constraint_name | 'DROP' 'CONSTRAINT' 'IF' 'EXISTS' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' 'CONSTRAINT' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'EXPERIMENTAL_AUDIT' 'SET' ( 'READ' 'WRITE' | 'OFF' ) | ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) | 'PARTITION' 'ALL' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) | 'SET' '(' ( ( ( storage_parameter_key '=' value ) ) ( ( ',' ( storage_parameter_key '=' value ) ) )* ) ')' | 'RESET' '(' ( ( storage_parameter_key ) ( ( ',' storage_parameter_key ) )* ) ')' ) ) ( ( ',' ( 'RENAME' ( 'COLUMN' | ) column_name 'TO' column_new_name | 'RENAME' 'CONSTRAINT' constraint_name 'TO' constraint_new_name | 'ADD' ( column_name typename ( ( ) ( ( col_qualification ) )* ) ) | 'ADD' 'IF' 'NOT' 'EXISTS' ( column_name typename ( ( ) ( ( col_qualification ) )* ) ) | 'ADD' 'COLUMN' ( column_name typename ( ( ) ( ( col_qualification ) )* ) ) | 'ADD' 'COLUMN' 'IF' 'NOT' 'EXISTS' ( column_name typename ( ( ) ( ( col_qualification ) )* ) ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DEFAULT' a_expr | 'DROP' 'DEFAULT' ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'ON' 'UPDATE' b_expr | 'DROP' 'ON' 'UPDATE' ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'VISIBLE' | 'SET' 'NOT' 'VISIBLE' ) | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'NOT' 'NULL' | 'ALTER' ( 'COLUMN' | ) column_name 'DROP' 'STORED' | 'ALTER' ( 'COLUMN' | ) column_name 'SET' 'NOT' 'NULL' | 'DROP' ( 'COLUMN' | ) 'IF' 'EXISTS' column_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' ( 'COLUMN' | ) column_name ( 'CASCADE' | 'RESTRICT' | ) | 'ALTER' ( 'COLUMN' | ) column_name ( 'SET' 'DATA' | ) 'TYPE' typename ( 'COLLATE' collation_name | ) ( 'USING' a_expr | ) | 'ADD' ( 'CONSTRAINT' constraint_name constraint_elem | constraint_elem ) ( 'NOT' 'VALID' | ) | 'ADD' 'CONSTRAINT' 'IF' 'NOT' 'EXISTS' constraint_name constraint_elem ( 'NOT' 'VALID' | ) | 'ALTER' 'PRIMARY' 'KEY' 'USING' 'COLUMNS' '(' index_params ')' ( 'USING' 'HASH' | ) ( 'WITH' '(' ( ( ( storage_parameter_key '=' value ) ) ( ( ',' ( storage_parameter_key '=' value ) ) )* ) ')' ) | 'VALIDATE' 'CONSTRAINT' constraint_name | 'DROP' 'CONSTRAINT' 'IF' 'EXISTS' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'DROP' 'CONSTRAINT' constraint_name ( 'CASCADE' | 'RESTRICT' | ) | 'EXPERIMENTAL_AUDIT' 'SET' ( 'READ' 'WRITE' | 'OFF' ) | ( ( 'PARTITION' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) | 'PARTITION' 'ALL' 'BY' ( 'LIST' '(' name_list ')' '(' list_partitions ')' | 'RANGE' '(' name_list ')' '(' range_partitions ')' | 'NOTHING' ) ) | 'SET' '(' ( ( ( storage_parameter_key '=' value ) ) ( ( ',' ( storage_parameter_key '=' value ) ) )* ) ')' | 'RESET' '(' ( ( storage_parameter_key ) ( ( ',' storage_parameter_key ) )* ) ')' ) ) )* diff --git a/docs/generated/sql/bnf/alter_view.bnf b/docs/generated/sql/bnf/alter_view.bnf index 7c640c97e891..e249309d2db1 100644 --- a/docs/generated/sql/bnf/alter_view.bnf +++ b/docs/generated/sql/bnf/alter_view.bnf @@ -1,8 +1,8 @@ alter_view_stmt ::= - 'ALTER' 'VIEW' view_name 'RENAME' 'TO' view_name - | 'ALTER' 'MATERIALIZED' 'VIEW' view_name 'RENAME' 'TO' view_name - | 'ALTER' 'VIEW' 'IF' 'EXISTS' view_name 'RENAME' 'TO' view_name - | 'ALTER' 'MATERIALIZED' 'VIEW' 'IF' 'EXISTS' view_name 'RENAME' 'TO' view_name + 'ALTER' 'VIEW' view_name 'RENAME' 'TO' view_new_name + | 'ALTER' 'MATERIALIZED' 'VIEW' view_name 'RENAME' 'TO' view_new_name + | 'ALTER' 'VIEW' 'IF' 'EXISTS' view_name 'RENAME' 'TO' view_new_name + | 'ALTER' 'MATERIALIZED' 'VIEW' 'IF' 'EXISTS' view_name 'RENAME' 'TO' view_new_name | 'ALTER' 'VIEW' view_name 'SET' 'SCHEMA' schema_name | 'ALTER' 'MATERIALIZED' 'VIEW' view_name 'SET' 'SCHEMA' schema_name | 'ALTER' 'VIEW' 'IF' 'EXISTS' view_name 'SET' 'SCHEMA' schema_name diff --git a/docs/generated/sql/bnf/create_database_stmt.bnf b/docs/generated/sql/bnf/create_database_stmt.bnf index 3e80adca36a1..9cf306e97eb1 100644 --- a/docs/generated/sql/bnf/create_database_stmt.bnf +++ b/docs/generated/sql/bnf/create_database_stmt.bnf @@ -1,3 +1,3 @@ create_database_stmt ::= - 'CREATE' 'DATABASE' database_name ( 'WITH' | ) opt_template_clause ( 'ENCODING' ( '=' | ) encoding | ) opt_lc_collate_clause opt_lc_ctype_clause ( 'CONNECTION' 'LIMIT' ( '=' | ) limit | ) ( ( 'PRIMARY' 'REGION' ( '=' | ) region_name ) | ) ( ( 'REGIONS' ) ( '=' | ) region_name_list | ) ( ( 'SURVIVE' ( '=' | ) 'REGION' 'FAILURE' | 'SURVIVE' ( '=' | ) 'ZONE' 'FAILURE' ) | ) opt_owner_clause opt_super_region_clause opt_secondary_region_clause - | 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name ( 'WITH' | ) opt_template_clause ( 'ENCODING' ( '=' | ) encoding | ) opt_lc_collate_clause opt_lc_ctype_clause ( 'CONNECTION' 'LIMIT' ( '=' | ) limit | ) ( ( 'PRIMARY' 'REGION' ( '=' | ) region_name ) | ) ( ( 'REGIONS' ) ( '=' | ) region_name_list | ) ( ( 'SURVIVE' ( '=' | ) 'REGION' 'FAILURE' | 'SURVIVE' ( '=' | ) 'ZONE' 'FAILURE' ) | ) opt_super_region_clause opt_secondary_region_clause + 'CREATE' 'DATABASE' database_name ( 'WITH' | ) opt_template_clause ( 'ENCODING' ( '=' | ) encoding | ) opt_lc_collate_clause opt_lc_ctype_clause ( 'CONNECTION' 'LIMIT' ( '=' | ) limit | ) ( ( 'PRIMARY' 'REGION' ( '=' | ) region_name ) | ) ( ( 'REGIONS' ) ( '=' | ) region_name_list | ) ( ( 'SURVIVE' ( '=' | ) 'REGION' 'FAILURE' | 'SURVIVE' ( '=' | ) 'ZONE' 'FAILURE' ) | ) opt_placement_clause opt_owner_clause opt_super_region_clause opt_secondary_region_clause + | 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name ( 'WITH' | ) opt_template_clause ( 'ENCODING' ( '=' | ) encoding | ) opt_lc_collate_clause opt_lc_ctype_clause ( 'CONNECTION' 'LIMIT' ( '=' | ) limit | ) ( ( 'PRIMARY' 'REGION' ( '=' | ) region_name ) | ) ( ( 'REGIONS' ) ( '=' | ) region_name_list | ) ( ( 'SURVIVE' ( '=' | ) 'REGION' 'FAILURE' | 'SURVIVE' ( '=' | ) 'ZONE' 'FAILURE' ) | ) opt_placement_clause opt_super_region_clause opt_secondary_region_clause diff --git a/docs/generated/sql/bnf/stmt_block.bnf b/docs/generated/sql/bnf/stmt_block.bnf index 62735d5dc9be..3ccf1474840e 100644 --- a/docs/generated/sql/bnf/stmt_block.bnf +++ b/docs/generated/sql/bnf/stmt_block.bnf @@ -1588,6 +1588,8 @@ alter_database_stmt ::= | alter_database_drop_region_stmt | alter_database_survival_goal_stmt | alter_database_primary_region_stmt + | alter_database_placement_stmt + | alter_database_set_stmt | alter_database_add_super_region | alter_database_alter_super_region | alter_database_drop_super_region @@ -1669,8 +1671,8 @@ for_schedules_clause ::= | 'FOR' 'SCHEDULE' a_expr create_database_stmt ::= - 'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_primary_region_clause opt_regions_list opt_survival_goal_clause opt_owner_clause opt_super_region_clause opt_secondary_region_clause - | 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_primary_region_clause opt_regions_list opt_survival_goal_clause opt_super_region_clause opt_secondary_region_clause + 'CREATE' 'DATABASE' database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_primary_region_clause opt_regions_list opt_survival_goal_clause opt_placement_clause opt_owner_clause opt_super_region_clause opt_secondary_region_clause + | 'CREATE' 'DATABASE' 'IF' 'NOT' 'EXISTS' database_name opt_with opt_template_clause opt_encoding_clause opt_lc_collate_clause opt_lc_ctype_clause opt_connection_limit opt_primary_region_clause opt_regions_list opt_survival_goal_clause opt_placement_clause opt_super_region_clause opt_secondary_region_clause create_index_stmt ::= 'CREATE' opt_unique 'INDEX' opt_concurrently opt_index_name 'ON' table_name opt_index_access_method '(' index_params ')' opt_hash_sharded opt_storing opt_partition_by_index opt_with_storage_parameter_list opt_where_clause opt_index_visible @@ -2143,6 +2145,12 @@ alter_database_primary_region_stmt ::= 'ALTER' 'DATABASE' database_name primary_region_clause | 'ALTER' 'DATABASE' database_name 'SET' primary_region_clause +alter_database_placement_stmt ::= + 'ALTER' 'DATABASE' database_name placement_clause + +alter_database_set_stmt ::= + 'ALTER' 'DATABASE' database_name set_or_reset_clause + alter_database_add_super_region ::= 'ALTER' 'DATABASE' database_name 'ADD' 'SUPER' 'REGION' name 'VALUES' name_list @@ -2309,6 +2317,10 @@ opt_survival_goal_clause ::= survival_goal_clause | +opt_placement_clause ::= + placement_clause + | + opt_owner_clause ::= 'OWNER' opt_equal role_spec | @@ -2808,6 +2820,10 @@ survival_goal_clause ::= primary_region_clause ::= 'PRIMARY' 'REGION' opt_equal region_name +placement_clause ::= + 'PLACEMENT' 'RESTRICTED' + | 'PLACEMENT' 'DEFAULT' + secondary_region_clause ::= 'SECONDARY' 'REGION' opt_equal region_name diff --git a/pkg/ccl/streamingccl/streamingest/metrics.go b/pkg/ccl/streamingccl/streamingest/metrics.go index 58c3c7910d82..a58ba3fb2ca6 100644 --- a/pkg/ccl/streamingccl/streamingest/metrics.go +++ b/pkg/ccl/streamingccl/streamingest/metrics.go @@ -34,6 +34,12 @@ var ( Measurement: "Bytes", Unit: metric.Unit_BYTES, } + metaStreamingSSTBytes = metric.Metadata{ + Name: "streaming.sst_bytes", + Help: "SST bytes (compressed) sent to KV by all ingestion jobs", + Measurement: "Bytes", + Unit: metric.Unit_BYTES, + } metaStreamingFlushes = metric.Metadata{ Name: "streaming.flushes", Help: "Total flushes across all ingestion jobs", @@ -110,6 +116,7 @@ var ( type Metrics struct { IngestedEvents *metric.Counter IngestedBytes *metric.Counter + SSTBytes *metric.Counter Flushes *metric.Counter JobProgressUpdates *metric.Counter ResolvedEvents *metric.Counter @@ -132,6 +139,7 @@ func MakeMetrics(histogramWindow time.Duration) metric.Struct { m := &Metrics{ IngestedEvents: metric.NewCounter(metaStreamingEventsIngested), IngestedBytes: metric.NewCounter(metaStreamingIngestedBytes), + SSTBytes: metric.NewCounter(metaStreamingSSTBytes), Flushes: metric.NewCounter(metaStreamingFlushes), ResolvedEvents: metric.NewCounter(metaStreamingResolvedEventsIngested), JobProgressUpdates: metric.NewCounter(metaJobProgressUpdates), diff --git a/pkg/ccl/streamingccl/streamingest/stream_ingestion_processor.go b/pkg/ccl/streamingccl/streamingest/stream_ingestion_processor.go index 5e8a42fdbbe3..18a6e961dab9 100644 --- a/pkg/ccl/streamingccl/streamingest/stream_ingestion_processor.go +++ b/pkg/ccl/streamingccl/streamingest/stream_ingestion_processor.go @@ -825,6 +825,7 @@ func (sip *streamIngestionProcessor) flush() (*jobspb.ResolvedSpans, error) { sip.metrics.CommitLatency.RecordValue(timeutil.Since(minBatchMVCCTimestamp.GoTime()).Nanoseconds()) sip.metrics.Flushes.Inc(1) sip.metrics.IngestedBytes.Inc(int64(totalSize)) + sip.metrics.SSTBytes.Inc(sip.batcher.GetSummary().SSTDataSize) sip.metrics.IngestedEvents.Inc(int64(len(sip.curKVBatch))) sip.metrics.IngestedEvents.Inc(int64(sip.rangeBatcher.size())) }() diff --git a/pkg/cmd/docgen/diagrams.go b/pkg/cmd/docgen/diagrams.go index ef0d8f3622bf..759536df3ef0 100644 --- a/pkg/cmd/docgen/diagrams.go +++ b/pkg/cmd/docgen/diagrams.go @@ -399,6 +399,16 @@ var specs = []stmtSpec{ exclude: []*regexp.Regexp{regexp.MustCompile("relation_expr 'ALTER' 'PRIMARY' 'KEY' ")}, unlink: []string{"table_name"}, }, + { + name: "alter_database", + stmt: "alter_database_stmt", + inline: []string{"alter_rename_database_stmt", "alter_zone_database_stmt", "alter_database_owner", "alter_database_to_schema_stmt", "alter_database_add_region_stmt", "alter_database_drop_region_stmt", "alter_database_survival_goal_stmt", "alter_database_set_stmt", "alter_database_primary_region_stmt", "alter_database_placement_stmt", "opt_equal", "alter_database_add_super_region", "alter_database_alter_super_region", "alter_database_drop_super_region", "alter_database_set_secondary_region_stmt", "alter_database_drop_secondary_region", "alter_database_set_zone_config_extension_stmt", "set_zone_config", "var_set_list", "survival_goal_clause", "primary_region_clause", "placement_clause", "secondary_region_clause", "set_or_reset_clause", "set_rest", "generic_set", "var_list", "to_or_eq"}, + replace: map[string]string{"'RENAME' 'TO' database_name": "'RENAME' 'TO' database_new_name", "'SUPER' 'REGION' name": "'SUPER' 'REGION' region_name", "'VALUES' name_list": "'VALUES' region_name_list", "var_name": "variable", "var_value": "value"}, + unlink: []string{"database_new_name", "region_name_list", "variable", "value"}, + }, + { + name: "alter_database_stmt", + }, { name: "alter_database_primary_region", stmt: "alter_database_primary_region_stmt", @@ -413,6 +423,31 @@ var specs = []stmtSpec{ inline: []string{"opt_for_roles", "role_or_group_or_user", "name_list", "opt_in_schemas", "schema_name_list", "abbreviated_grant_stmt", "opt_with_grant_option", "target_object_type", "abbreviated_revoke_stmt", "opt_drop_behavior"}, nosplit: true, }, + { + name: "alter_index", + stmt: "alter_index_stmt", + inline: []string{"alter_oneindex_stmt", "alter_index_cmds", "alter_index_cmd", "partition_by_index", "partition_by_inner", "partition_by", "table_index_name", "alter_split_index_stmt", "alter_unsplit_index_stmt", "alter_rename_index_stmt", "alter_zone_index_stmt", "var_set_list", "alter_index_visible_stmt", "set_zone_config", "alter_index_visible"}, + exclude: []*regexp.Regexp{regexp.MustCompile("alter_scatter_index_stmt")}, + replace: map[string]string{"standalone_index_name": "index_name", "var_name": "variable", "var_value": "value", "'RENAME' 'TO' index_name": "'RENAME' 'TO' index_new_name"}, + unlink: []string{"index_new_name", "variable", "value"}, + }, + { + name: "alter_index_stmt", + }, + { + name: "alter_range", + stmt: "alter_range_stmt", + inline: []string{"alter_zone_range_stmt", "alter_range_relocate_stmt", "var_set_list", "set_zone_config", "relocate_kw", "relocate_subject_nonlease"}, + exclude: []*regexp.Regexp{ + regexp.MustCompile("TESTING_RELOCATE"), + regexp.MustCompile("EXPERIMENTAL_RELOCATE"), + }, + replace: map[string]string{"'RANGE' a_expr": "'RANGE' range_id"}, + unlink: []string{"range_id"}, + }, + { + name: "alter_range_stmt", + }, { name: "alter_table_reset_storage_param", stmt: "alter_onetable_stmt", @@ -485,7 +520,8 @@ var specs = []stmtSpec{ { name: "alter_func_stmt", inline: []string{"alter_func_options_stmt", "alter_func_rename_stmt", "alter_func_owner_stmt", "alter_func_set_schema_stmt", "alter_func_dep_extension_stmt", "alter_func_opt_list", "common_func_opt_item", "opt_restrict", "opt_no"}, - unlink: []string{"alter_func_options_stmt", "alter_func_rename_stmt", "alter_func_owner_stmt", "alter_func_set_schema_stmt", "alter_func_dep_extension_stmt", "alter_func_opt_list", "common_func_opt_item", "opt_restrict", "opt_no"}, + replace: map[string]string{"'RENAME' 'TO' name": "'RENAME' 'TO' function_new_name"}, + unlink: []string{"alter_func_options_stmt", "alter_func_rename_stmt", "alter_func_owner_stmt", "alter_func_set_schema_stmt", "alter_func_dep_extension_stmt", "alter_func_opt_list", "common_func_opt_item", "opt_restrict", "opt_no", "function_new_name"}, nosplit: true, }, { @@ -501,6 +537,8 @@ var specs = []stmtSpec{ name: "alter_schema", stmt: "alter_schema_stmt", inline: []string{"qualifiable_schema_name"}, + replace: map[string]string{"schema_name": "schema_new_name"}, + unlink: []string{"schema_new_name"}, nosplit: true, }, { @@ -512,16 +550,21 @@ var specs = []stmtSpec{ nosplit: true, }, { - name: "alter_table", - stmt: "alter_onetable_stmt", - inline: []string{"alter_table_cmds", "alter_table_cmd", "column_table_def", "opt_drop_behavior", "alter_column_default", "opt_column", "opt_set_data", "table_constraint", "opt_collate", "opt_alter_column_using"}, - replace: map[string]string{ - "'VALIDATE' 'CONSTRAINT' name": "", - "opt_validate_behavior": "", - "relation_expr": "table_name", - "alter_column_visible": "'SET' ('NOT' | ) 'VISIBLE'", - }, - unlink: []string{"table_name"}, + name: "alter_table", + stmt: "alter_table_stmt", + inline: []string{"alter_onetable_stmt", "alter_table_cmds", "alter_split_stmt", "alter_unsplit_stmt", "alter_zone_table_stmt", "alter_rename_table_stmt", "alter_table_set_schema_stmt", "alter_table_locality_stmt", "alter_table_owner_stmt", "set_zone_config", "var_set_list"}, + exclude: []*regexp.Regexp{regexp.MustCompile("alter_scatter_stmt")}, + replace: map[string]string{"relation_expr": "table_name", "'RENAME' 'TO' table_name": "'RENAME' 'TO' table_new_name", "var_name": "variable", "var_value": "value"}, + unlink: []string{"table_name", "table_new_name", "variable", "value"}, + }, + { + name: "alter_table_stmt", + }, + { + name: "alter_table_cmds", + inline: []string{"alter_table_cmd", "column_table_def", "col_qual_list", "opt_column", "opt_validate_behavior", "table_constraint", "alter_column_default", "alter_column_visible", "opt_set_data", "opt_collate", "opt_alter_column_using", "alter_column_on_update", "opt_hash_sharded", "opt_with_storage_parameter_list", "opt_drop_behavior", "audit_mode", "partition_by", "partition_by_table", "partition_by_inner", "storage_parameter_list", "storage_parameter", "storage_parameter_key_list"}, + replace: map[string]string{"'RENAME' ( 'COLUMN' | ) column_name 'TO' column_name": "'RENAME' ( 'COLUMN' | ) column_name 'TO' column_new_name", "'RENAME' 'CONSTRAINT' column_name 'TO' column_name": "'RENAME' 'CONSTRAINT' constraint_name 'TO' constraint_new_name", "opt_hash_sharded_bucket_count ": "", "var_name": "variable", "var_value": "value"}, + unlink: []string{"column_new_name", "constraint_name", "constraint_new_name", "variable", "value"}, nosplit: true, }, { @@ -535,7 +578,8 @@ var specs = []stmtSpec{ name: "alter_view", stmt: "alter_view_stmt", inline: []string{"alter_rename_view_stmt", "alter_view_set_schema_stmt", "alter_view_owner_stmt", "opt_transaction"}, - replace: map[string]string{"relation_expr": "view_name", "qualified_name": "name"}, unlink: []string{"view_name", "name"}, + replace: map[string]string{"relation_expr": "view_name", "'RENAME' 'TO' view_name": "'RENAME' 'TO' view_new_name"}, + unlink: []string{"view_name", "view_new_name"}, }, { name: "alter_zone_database_stmt", diff --git a/pkg/gen/bnf.bzl b/pkg/gen/bnf.bzl index bd9fc1401e6b..b22742da50e5 100644 --- a/pkg/gen/bnf.bzl +++ b/pkg/gen/bnf.bzl @@ -8,6 +8,7 @@ BNF_SRCS = [ "//docs/generated/sql/bnf:alter_backup_schedule.bnf", "//docs/generated/sql/bnf:alter_changefeed.bnf", "//docs/generated/sql/bnf:alter_column.bnf", + "//docs/generated/sql/bnf:alter_database.bnf", "//docs/generated/sql/bnf:alter_database_add_region_stmt.bnf", "//docs/generated/sql/bnf:alter_database_add_super_region.bnf", "//docs/generated/sql/bnf:alter_database_alter_super_region.bnf", @@ -15,8 +16,10 @@ BNF_SRCS = [ "//docs/generated/sql/bnf:alter_database_drop_secondary_region.bnf", "//docs/generated/sql/bnf:alter_database_drop_super_region.bnf", "//docs/generated/sql/bnf:alter_database_owner.bnf", + "//docs/generated/sql/bnf:alter_database_placement_stmt.bnf", "//docs/generated/sql/bnf:alter_database_primary_region.bnf", "//docs/generated/sql/bnf:alter_database_set_secondary_region_stmt.bnf", + "//docs/generated/sql/bnf:alter_database_set_stmt.bnf", "//docs/generated/sql/bnf:alter_database_set_zone_config_extension_stmt.bnf", "//docs/generated/sql/bnf:alter_database_stmt.bnf", "//docs/generated/sql/bnf:alter_database_survival_goal_stmt.bnf", @@ -29,11 +32,13 @@ BNF_SRCS = [ "//docs/generated/sql/bnf:alter_func_rename_stmt.bnf", "//docs/generated/sql/bnf:alter_func_set_schema_stmt.bnf", "//docs/generated/sql/bnf:alter_func_stmt.bnf", + "//docs/generated/sql/bnf:alter_index.bnf", "//docs/generated/sql/bnf:alter_index_partition_by.bnf", "//docs/generated/sql/bnf:alter_index_stmt.bnf", "//docs/generated/sql/bnf:alter_index_visible_stmt.bnf", "//docs/generated/sql/bnf:alter_partition_stmt.bnf", "//docs/generated/sql/bnf:alter_primary_key.bnf", + "//docs/generated/sql/bnf:alter_range.bnf", "//docs/generated/sql/bnf:alter_range_relocate_stmt.bnf", "//docs/generated/sql/bnf:alter_range_stmt.bnf", "//docs/generated/sql/bnf:alter_rename_view_stmt.bnf", @@ -47,6 +52,7 @@ BNF_SRCS = [ "//docs/generated/sql/bnf:alter_sequence_set_schema_stmt.bnf", "//docs/generated/sql/bnf:alter_stmt.bnf", "//docs/generated/sql/bnf:alter_table.bnf", + "//docs/generated/sql/bnf:alter_table_cmds.bnf", "//docs/generated/sql/bnf:alter_table_locality_stmt.bnf", "//docs/generated/sql/bnf:alter_table_owner_stmt.bnf", "//docs/generated/sql/bnf:alter_table_partition_by.bnf", diff --git a/pkg/gen/diagrams.bzl b/pkg/gen/diagrams.bzl index 99f2c575f3d7..654330faec50 100644 --- a/pkg/gen/diagrams.bzl +++ b/pkg/gen/diagrams.bzl @@ -17,7 +17,9 @@ DIAGRAMS_SRCS = [ "//docs/generated/sql/bnf:alter_database_drop_secondary_region.html", "//docs/generated/sql/bnf:alter_database_drop_super_region.html", "//docs/generated/sql/bnf:alter_database_owner.html", + "//docs/generated/sql/bnf:alter_database_placement.html", "//docs/generated/sql/bnf:alter_database_primary_region.html", + "//docs/generated/sql/bnf:alter_database_set.html", "//docs/generated/sql/bnf:alter_database_set_secondary_region.html", "//docs/generated/sql/bnf:alter_database_set_zone_config_extension.html", "//docs/generated/sql/bnf:alter_database_survival_goal.html", @@ -47,6 +49,7 @@ DIAGRAMS_SRCS = [ "//docs/generated/sql/bnf:alter_sequence_owner.html", "//docs/generated/sql/bnf:alter_sequence_set_schema.html", "//docs/generated/sql/bnf:alter_table.html", + "//docs/generated/sql/bnf:alter_table_cmds.html", "//docs/generated/sql/bnf:alter_table_locality.html", "//docs/generated/sql/bnf:alter_table_owner.html", "//docs/generated/sql/bnf:alter_table_partition_by.html", diff --git a/pkg/gen/docs.bzl b/pkg/gen/docs.bzl index c72f0ad76b98..bad5180e4298 100644 --- a/pkg/gen/docs.bzl +++ b/pkg/gen/docs.bzl @@ -20,6 +20,7 @@ DOCS_SRCS = [ "//docs/generated/sql/bnf:alter_backup_schedule.bnf", "//docs/generated/sql/bnf:alter_changefeed.bnf", "//docs/generated/sql/bnf:alter_column.bnf", + "//docs/generated/sql/bnf:alter_database.bnf", "//docs/generated/sql/bnf:alter_database_add_region_stmt.bnf", "//docs/generated/sql/bnf:alter_database_add_super_region.bnf", "//docs/generated/sql/bnf:alter_database_alter_super_region.bnf", @@ -27,8 +28,10 @@ DOCS_SRCS = [ "//docs/generated/sql/bnf:alter_database_drop_secondary_region.bnf", "//docs/generated/sql/bnf:alter_database_drop_super_region.bnf", "//docs/generated/sql/bnf:alter_database_owner.bnf", + "//docs/generated/sql/bnf:alter_database_placement_stmt.bnf", "//docs/generated/sql/bnf:alter_database_primary_region.bnf", "//docs/generated/sql/bnf:alter_database_set_secondary_region_stmt.bnf", + "//docs/generated/sql/bnf:alter_database_set_stmt.bnf", "//docs/generated/sql/bnf:alter_database_set_zone_config_extension_stmt.bnf", "//docs/generated/sql/bnf:alter_database_stmt.bnf", "//docs/generated/sql/bnf:alter_database_survival_goal_stmt.bnf", @@ -41,11 +44,13 @@ DOCS_SRCS = [ "//docs/generated/sql/bnf:alter_func_rename_stmt.bnf", "//docs/generated/sql/bnf:alter_func_set_schema_stmt.bnf", "//docs/generated/sql/bnf:alter_func_stmt.bnf", + "//docs/generated/sql/bnf:alter_index.bnf", "//docs/generated/sql/bnf:alter_index_partition_by.bnf", "//docs/generated/sql/bnf:alter_index_stmt.bnf", "//docs/generated/sql/bnf:alter_index_visible_stmt.bnf", "//docs/generated/sql/bnf:alter_partition_stmt.bnf", "//docs/generated/sql/bnf:alter_primary_key.bnf", + "//docs/generated/sql/bnf:alter_range.bnf", "//docs/generated/sql/bnf:alter_range_relocate_stmt.bnf", "//docs/generated/sql/bnf:alter_range_stmt.bnf", "//docs/generated/sql/bnf:alter_rename_view_stmt.bnf", @@ -59,6 +64,7 @@ DOCS_SRCS = [ "//docs/generated/sql/bnf:alter_sequence_set_schema_stmt.bnf", "//docs/generated/sql/bnf:alter_stmt.bnf", "//docs/generated/sql/bnf:alter_table.bnf", + "//docs/generated/sql/bnf:alter_table_cmds.bnf", "//docs/generated/sql/bnf:alter_table_locality_stmt.bnf", "//docs/generated/sql/bnf:alter_table_owner_stmt.bnf", "//docs/generated/sql/bnf:alter_table_partition_by.bnf", diff --git a/pkg/gossip/BUILD.bazel b/pkg/gossip/BUILD.bazel index 0e8be78336f1..e6ab88581b04 100644 --- a/pkg/gossip/BUILD.bazel +++ b/pkg/gossip/BUILD.bazel @@ -42,7 +42,6 @@ go_library( "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_logtags//:logtags", "@com_github_cockroachdb_redact//:redact", - "@org_golang_google_grpc//:go_default_library", ], ) diff --git a/pkg/gossip/client_test.go b/pkg/gossip/client_test.go index fb63f44f93d1..4e6c63097287 100644 --- a/pkg/gossip/client_test.go +++ b/pkg/gossip/client_test.go @@ -41,7 +41,7 @@ func startGossip( stopper *stop.Stopper, t *testing.T, registry *metric.Registry, -) *Gossip { +) (*Gossip, *rpc.Context) { return startGossipAtAddr(clusterID, nodeID, util.IsolatedTestAddr, stopper, t, registry) } @@ -52,14 +52,15 @@ func startGossipAtAddr( stopper *stop.Stopper, t *testing.T, registry *metric.Registry, -) *Gossip { +) (*Gossip, *rpc.Context) { ctx := context.Background() clock := hlc.NewClockWithSystemTimeSource(time.Nanosecond /* maxOffset */) rpcContext := rpc.NewInsecureTestingContextWithClusterID(ctx, clock, stopper, clusterID) rpcContext.NodeID.Set(ctx, nodeID) server := rpc.NewServer(rpcContext) - g := NewTest(nodeID, rpcContext, server, stopper, registry, zonepb.DefaultZoneConfigRef()) + g := NewTest(nodeID, stopper, registry, zonepb.DefaultZoneConfigRef()) + RegisterGossipServer(server, g) ln, err := netutil.ListenAndServeGRPC(stopper, server, addr) if err != nil { t.Fatal(err) @@ -73,7 +74,7 @@ func startGossipAtAddr( } g.start(addr) time.Sleep(time.Millisecond) - return g + return g, rpcContext } type fakeGossipServer struct { @@ -121,7 +122,8 @@ func startFakeServerGossips( lRPCContext := rpc.NewInsecureTestingContextWithClusterID(ctx, clock, stopper, clusterID) lserver := rpc.NewServer(lRPCContext) - local := NewTest(localNodeID, lRPCContext, lserver, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + local := NewTest(localNodeID, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + RegisterGossipServer(lserver, local) lln, err := netutil.ListenAndServeGRPC(stopper, lserver, util.IsolatedTestAddr) if err != nil { t.Fatal(err) @@ -184,8 +186,8 @@ func TestClientGossip(t *testing.T) { ctx := context.Background() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) - remote := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) + local, _ := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + remote, _ := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) disconnected := make(chan *client, 1) c := newClient(log.MakeTestingAmbientCtxWithNewTracer(), remote.GetNodeAddr(), makeMetrics()) @@ -226,8 +228,8 @@ func TestClientGossipMetrics(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) - remote := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) + local, _ := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + remote, _ := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) if err := local.AddInfo("local-key", nil, time.Hour); err != nil { t.Fatal(err) @@ -341,12 +343,12 @@ func TestClientDisconnectLoopback(t *testing.T) { ctx := context.Background() stopper := stop.NewStopper() defer stopper.Stop(ctx) - local := startGossip(uuid.Nil, 1, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(uuid.Nil, 1, stopper, t, metric.NewRegistry()) local.mu.Lock() lAddr := local.mu.is.NodeAddr - local.startClientLocked(lAddr) + local.startClientLocked(lAddr, localCtx) local.mu.Unlock() - local.manage() + local.manage(localCtx) testutils.SucceedsSoon(t, func() error { ok := local.findClient(func(c *client) bool { return c.addr.String() == lAddr.String() }) != nil if !ok && verifyServerMaps(local, 0) { @@ -368,16 +370,16 @@ func TestClientDisconnectRedundant(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) - remote := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + remote, remoteCtx := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) local.mu.Lock() remote.mu.Lock() rAddr := remote.mu.is.NodeAddr lAddr := local.mu.is.NodeAddr local.mu.Unlock() remote.mu.Unlock() - local.manage() - remote.manage() + local.manage(localCtx) + remote.manage(remoteCtx) // Gossip a key on local and wait for it to show up on remote. This // guarantees we have an active local to remote client connection. @@ -390,7 +392,7 @@ func TestClientDisconnectRedundant(t *testing.T) { // Restart the client connection in the loop. It might have failed due to // a heartbeat time. local.mu.Lock() - local.startClientLocked(rAddr) + local.startClientLocked(rAddr, localCtx) local.mu.Unlock() return fmt.Errorf("unable to find local to remote client") } @@ -401,7 +403,7 @@ func TestClientDisconnectRedundant(t *testing.T) { // Start a remote to local client. This client will get removed as being // redundant as there is already a connection between the two nodes. remote.mu.Lock() - remote.startClientLocked(lAddr) + remote.startClientLocked(lAddr, remoteCtx) remote.mu.Unlock() testutils.SucceedsSoon(t, func() error { @@ -427,8 +429,8 @@ func TestClientDisallowMultipleConns(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) - remote := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + remote, remoteCtx := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) local.mu.Lock() remote.mu.Lock() @@ -436,12 +438,12 @@ func TestClientDisallowMultipleConns(t *testing.T) { // Start two clients from local to remote. RPC client cache is // disabled via the context, so we'll start two different outgoing // connections. - local.startClientLocked(rAddr) - local.startClientLocked(rAddr) + local.startClientLocked(rAddr, localCtx) + local.startClientLocked(rAddr, localCtx) local.mu.Unlock() remote.mu.Unlock() - local.manage() - remote.manage() + local.manage(localCtx) + remote.manage(remoteCtx) testutils.SucceedsSoon(t, func() error { // Verify that the remote server has only a single incoming // connection and the local server has only a single outgoing @@ -480,9 +482,8 @@ func TestClientRegisterWithInitNodeID(t *testing.T) { rpcContext := rpc.NewInsecureTestingContextWithClusterID(ctx, clock, stopper, clusterID) server := rpc.NewServer(rpcContext) // node ID must be non-zero - gnode := NewTest( - nodeID, rpcContext, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef(), - ) + gnode := NewTest(nodeID, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + RegisterGossipServer(server, gnode) g = append(g, gnode) ln, err := netutil.ListenAndServeGRPC(stopper, server, util.IsolatedTestAddr) @@ -496,7 +497,7 @@ func TestClientRegisterWithInitNodeID(t *testing.T) { } addresses := []util.UnresolvedAddr{util.MakeUnresolvedAddr("tcp", gossipAddr)} - gnode.Start(ln.Addr(), addresses) + gnode.Start(ln.Addr(), addresses, rpcContext) } testutils.SucceedsSoon(t, func() error { @@ -518,7 +519,7 @@ func TestClientForwardUnresolved(t *testing.T) { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) const nodeID = 1 - local := startGossip(uuid.Nil, nodeID, stopper, t, metric.NewRegistry()) + local, _ := startGossip(uuid.Nil, nodeID, stopper, t, metric.NewRegistry()) addr := local.GetNodeAddr() client := newClient(log.MakeTestingAmbientCtxWithNewTracer(), addr, makeMetrics()) // never started diff --git a/pkg/gossip/gossip.go b/pkg/gossip/gossip.go index 20bc448f3e43..924fa8348a1d 100644 --- a/pkg/gossip/gossip.go +++ b/pkg/gossip/gossip.go @@ -76,7 +76,6 @@ import ( "github.com/cockroachdb/errors" "github.com/cockroachdb/logtags" "github.com/cockroachdb/redact" - "google.golang.org/grpc" ) const ( @@ -222,7 +221,6 @@ type Gossip struct { Connected chan struct{} // Closed upon initial connection hasConnected bool // Set first time network is connected - rpcContext *rpc.Context // The context required for RPC outgoing nodeSet // Set of outgoing client node IDs storage Storage // Persistent storage interface bootstrapInfo BootstrapInfo // BootstrapInfo proto for persistent storage @@ -276,24 +274,12 @@ type Gossip struct { // New creates an instance of a gossip node. // The higher level manages the ClusterIDContainer and NodeIDContainer instances -// (which can be shared by various server components). The ambient context is -// expected to already contain the node ID. -// -// grpcServer: The server on which the new Gossip instance will register its RPC -// -// service. Can be nil, in which case the Gossip will not register the -// service. -// -// rpcContext: The context used to connect to other nodes. Can be nil for tests -// -// that also specify a nil grpcServer and that plan on using the Gossip in a -// restricted way by populating it with data manually. +// (which can be shared by various server components). +// The struct returned is started by calling Start and passing a rpc.Context. func New( ambient log.AmbientContext, clusterID *base.ClusterIDContainer, nodeID *base.NodeIDContainer, - rpcContext *rpc.Context, - grpcServer *grpc.Server, stopper *stop.Stopper, registry *metric.Registry, locality roachpb.Locality, @@ -303,7 +289,6 @@ func New( g := &Gossip{ server: newServer(ambient, clusterID, nodeID, stopper, registry), Connected: make(chan struct{}), - rpcContext: rpcContext, outgoing: makeNodeSet(minPeers, metric.NewGauge(MetaConnectionsOutgoingGauge)), bootstrapping: map[string]struct{}{}, disconnected: make(chan *client, 10), @@ -331,40 +316,23 @@ func New( g.mu.is.registerCallback(MakePrefixPattern(KeyStoreDescPrefix), g.updateStoreMap) g.mu.Unlock() - if grpcServer != nil { - RegisterGossipServer(grpcServer, g.server) - } return g } // NewTest is a simplified wrapper around New that creates the // ClusterIDContainer and NodeIDContainer internally. Used for testing. -// -// grpcServer: The server on which the new Gossip instance will register its RPC -// -// service. Can be nil, in which case the Gossip will not register the -// service. -// -// rpcContext: The context used to connect to other nodes. Can be nil for tests -// -// that also specify a nil grpcServer and that plan on using the Gossip in a -// restricted way by populating it with data manually. func NewTest( nodeID roachpb.NodeID, - rpcContext *rpc.Context, - grpcServer *grpc.Server, stopper *stop.Stopper, registry *metric.Registry, defaultZoneConfig *zonepb.ZoneConfig, ) *Gossip { - return NewTestWithLocality(nodeID, rpcContext, grpcServer, stopper, registry, roachpb.Locality{}, defaultZoneConfig) + return NewTestWithLocality(nodeID, stopper, registry, roachpb.Locality{}, defaultZoneConfig) } // NewTestWithLocality calls NewTest with an explicit locality value. func NewTestWithLocality( nodeID roachpb.NodeID, - rpcContext *rpc.Context, - grpcServer *grpc.Server, stopper *stop.Stopper, registry *metric.Registry, locality roachpb.Locality, @@ -374,7 +342,7 @@ func NewTestWithLocality( n := &base.NodeIDContainer{} var ac log.AmbientContext ac.AddLogTag("n", n) - gossip := New(ac, c, n, rpcContext, grpcServer, stopper, registry, locality, defaultZoneConfig) + gossip := New(ac, c, n, stopper, registry, locality, defaultZoneConfig) if nodeID != 0 { n.Set(context.TODO(), nodeID) } @@ -1173,15 +1141,20 @@ func (g *Gossip) MaxHops() uint32 { // instance in the gossip network; it will be used by other instances // to connect to this instance. // -// This method starts bootstrap loop, gossip server, and client -// management in separate goroutines and returns. -func (g *Gossip) Start(advertAddr net.Addr, addresses []util.UnresolvedAddr) { +// This method starts bootstrap loop, gossip server, and client management in +// separate goroutines and returns. +// +// The rpcContext is passed in here rather than at struct creation time to allow +// a looser coupling between the objects at construction. +func (g *Gossip) Start( + advertAddr net.Addr, addresses []util.UnresolvedAddr, rpcContext *rpc.Context, +) { g.AssertNotStarted(context.Background()) g.started = true g.setAddresses(addresses) g.server.start(advertAddr) // serve gossip protocol - g.bootstrap() // bootstrap gossip client - g.manage() // manage gossip clients + g.bootstrap(rpcContext) // bootstrap gossip client + g.manage(rpcContext) // manage gossip clients } // hasIncomingLocked returns whether the server has an incoming gossip @@ -1237,7 +1210,7 @@ func (g *Gossip) getNextBootstrapAddressLocked() util.UnresolvedAddr { // connection, this method will block on the stalled condvar, which // receives notifications that gossip network connectivity has been // lost and requires re-bootstrapping. -func (g *Gossip) bootstrap() { +func (g *Gossip) bootstrap(rpcContext *rpc.Context) { ctx := g.AnnotateCtx(context.Background()) _ = g.server.stopper.RunAsyncTask(ctx, "gossip-bootstrap", func(ctx context.Context) { ctx = logtags.AddTag(ctx, "bootstrap", nil) @@ -1253,7 +1226,7 @@ func (g *Gossip) bootstrap() { if !haveClients || !haveSentinel { // Try to get another bootstrap address. if addr := g.getNextBootstrapAddressLocked(); !addr.IsEmpty() { - g.startClientLocked(addr) + g.startClientLocked(addr, rpcContext) } else { bootstrapAddrs := make([]string, 0, len(g.bootstrapping)) for addr := range g.bootstrapping { @@ -1300,7 +1273,7 @@ func (g *Gossip) bootstrap() { // the outgoing address set. If there are no longer any outgoing // connections or the sentinel gossip is unavailable, the bootstrapper // is notified via the stalled conditional variable. -func (g *Gossip) manage() { +func (g *Gossip) manage(rpcContext *rpc.Context) { ctx := g.AnnotateCtx(context.Background()) _ = g.server.stopper.RunAsyncTask(ctx, "gossip-manage", func(ctx context.Context) { cullTimer := timeutil.NewTimer() @@ -1315,9 +1288,9 @@ func (g *Gossip) manage() { case <-g.server.stopper.ShouldQuiesce(): return case c := <-g.disconnected: - g.doDisconnected(c) + g.doDisconnected(c, rpcContext) case <-g.tighten: - g.tightenNetwork(ctx) + g.tightenNetwork(ctx, rpcContext) case <-cullTimer.C: cullTimer.Read = true cullTimer.Reset(jitteredInterval(g.cullInterval)) @@ -1335,7 +1308,7 @@ func (g *Gossip) manage() { // After releasing the lock, block until the client disconnects. defer func() { - g.doDisconnected(<-g.disconnected) + g.doDisconnected(<-g.disconnected, rpcContext) }() } else { if log.V(1) { @@ -1369,7 +1342,7 @@ func jitteredInterval(interval time.Duration) time.Duration { // client to the most distant node to which we don't already have an outgoing // connection. Does nothing if we don't have room for any more outgoing // connections. -func (g *Gossip) tightenNetwork(ctx context.Context) { +func (g *Gossip) tightenNetwork(ctx context.Context, rpcContext *rpc.Context) { g.mu.Lock() defer g.mu.Unlock() @@ -1395,19 +1368,19 @@ func (g *Gossip) tightenNetwork(ctx context.Context) { log.Health.Infof(ctx, "starting client to n%d (%d > %d) to tighten network graph", distantNodeID, distantHops, maxHops) log.Eventf(ctx, "tightening network with new client to %s", nodeAddr) - g.startClientLocked(*nodeAddr) + g.startClientLocked(*nodeAddr, rpcContext) } } } -func (g *Gossip) doDisconnected(c *client) { +func (g *Gossip) doDisconnected(c *client, rpcContext *rpc.Context) { g.mu.Lock() defer g.mu.Unlock() g.removeClientLocked(c) // If the client was disconnected with a forwarding address, connect now. if c.forwardAddr != nil { - g.startClientLocked(*c.forwardAddr) + g.startClientLocked(*c.forwardAddr, rpcContext) } g.maybeSignalStatusChangeLocked() } @@ -1479,20 +1452,20 @@ func (g *Gossip) signalConnectedLocked() { // startClientLocked launches a new client connected to remote address. // The client is added to the outgoing address set and launched in // a goroutine. -func (g *Gossip) startClientLocked(addr util.UnresolvedAddr) { +func (g *Gossip) startClientLocked(addr util.UnresolvedAddr, rpcContext *rpc.Context) { g.clientsMu.Lock() defer g.clientsMu.Unlock() breaker, ok := g.clientsMu.breakers[addr.String()] if !ok { - name := fmt.Sprintf("gossip %v->%v", g.rpcContext.Config.Addr, addr) - breaker = g.rpcContext.NewBreaker(name) + name := fmt.Sprintf("gossip %v->%v", rpcContext.Config.Addr, addr) + breaker = rpcContext.NewBreaker(name) g.clientsMu.breakers[addr.String()] = breaker } ctx := g.AnnotateCtx(context.TODO()) log.VEventf(ctx, 1, "starting new client to %s", addr) c := newClient(g.server.AmbientContext, &addr, g.serverMetrics) g.clientsMu.clients = append(g.clientsMu.clients, c) - c.startLocked(g, g.disconnected, g.rpcContext, g.server.stopper, breaker) + c.startLocked(g, g.disconnected, rpcContext, g.server.stopper, breaker) } // removeClientLocked removes the specified client. Called when a client diff --git a/pkg/gossip/gossip_test.go b/pkg/gossip/gossip_test.go index 92a6ebd6ad0e..0ff92997d95c 100644 --- a/pkg/gossip/gossip_test.go +++ b/pkg/gossip/gossip_test.go @@ -43,9 +43,7 @@ func TestGossipInfoStore(t *testing.T) { ctx := context.Background() stopper := stop.NewStopper() defer stopper.Stop(ctx) - clock := hlc.NewClockWithSystemTimeSource(time.Nanosecond /* maxOffset */) - rpcContext := rpc.NewInsecureTestingContext(ctx, clock, stopper) - g := NewTest(1, rpcContext, rpc.NewServer(rpcContext), stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) slice := []byte("b") if err := g.AddInfo("s", slice, time.Hour); err != nil { t.Fatal(err) @@ -65,9 +63,7 @@ func TestGossipMoveNode(t *testing.T) { ctx := context.Background() stopper := stop.NewStopper() defer stopper.Stop(ctx) - clock := hlc.NewClockWithSystemTimeSource(time.Nanosecond /* maxOffset */) - rpcContext := rpc.NewInsecureTestingContext(ctx, clock, stopper) - g := NewTest(1, rpcContext, rpc.NewServer(rpcContext), stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) var nodes []*roachpb.NodeDescriptor for i := 1; i <= 3; i++ { node := &roachpb.NodeDescriptor{ @@ -117,10 +113,7 @@ func TestGossipGetNextBootstrapAddress(t *testing.T) { util.MakeUnresolvedAddr("tcp", "localhost:9004"), } - clock := hlc.NewClockWithSystemTimeSource(time.Nanosecond /* maxOffset */) - rpcContext := rpc.NewInsecureTestingContext(ctx, clock, stopper) - server := rpc.NewServer(rpcContext) - g := NewTest(0, nil, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := NewTest(0, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) g.setAddresses(addresses) // Using specified addresses, fetch bootstrap addresses 3 times @@ -145,8 +138,6 @@ func TestGossipLocalityResolver(t *testing.T) { ctx := context.Background() stopper := stop.NewStopper() defer stopper.Stop(ctx) - clock := hlc.NewClockWithSystemTimeSource(time.Nanosecond /* maxOffset */) - rpcContext := rpc.NewInsecureTestingContext(ctx, clock, stopper) gossipLocalityAdvertiseList := roachpb.Locality{} tier := roachpb.Tier{} @@ -181,7 +172,7 @@ func TestGossipLocalityResolver(t *testing.T) { var node2LocalityList []roachpb.LocalityAddress node2LocalityList = append(node2LocalityList, nodeLocalityAddress2) - g := NewTestWithLocality(1, rpcContext, rpc.NewServer(rpcContext), stopper, metric.NewRegistry(), gossipLocalityAdvertiseList, zonepb.DefaultZoneConfigRef()) + g := NewTestWithLocality(1, stopper, metric.NewRegistry(), gossipLocalityAdvertiseList, zonepb.DefaultZoneConfigRef()) node1 := &roachpb.NodeDescriptor{ NodeID: 1, Address: node1PublicAddressRPC, @@ -236,11 +227,11 @@ func TestGossipRaceLogStatus(t *testing.T) { // Shared cluster ID by all gossipers (this ensures that the gossipers // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) local.mu.Lock() - peer := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) - local.startClientLocked(peer.mu.is.NodeAddr) + peer, _ := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) + local.startClientLocked(peer.mu.is.NodeAddr, localCtx) local.mu.Unlock() // Race gossiping against LogStatus. @@ -286,7 +277,7 @@ func TestGossipOutgoingLimitEnforced(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) local.mu.Lock() localAddr := local.mu.is.NodeAddr local.mu.Unlock() @@ -295,9 +286,9 @@ func TestGossipOutgoingLimitEnforced(t *testing.T) { // After creating a new node, join it to the first node to ensure that the // network is connected (and thus all nodes know each other's addresses) // before we start the actual test. - newPeer := startGossip(clusterID, roachpb.NodeID(i+2), stopper, t, metric.NewRegistry()) + newPeer, peerCtx := startGossip(clusterID, roachpb.NodeID(i+2), stopper, t, metric.NewRegistry()) newPeer.mu.Lock() - newPeer.startClientLocked(localAddr) + newPeer.startClientLocked(localAddr, peerCtx) newPeer.mu.Unlock() peers = append(peers, newPeer) } @@ -327,7 +318,7 @@ func TestGossipOutgoingLimitEnforced(t *testing.T) { t.Fatal(err) } for range peers { - local.tightenNetwork(context.Background()) + local.tightenNetwork(context.Background(), localCtx) } if outgoing := local.outgoing.gauge.Value(); outgoing > int64(maxPeers) { @@ -346,12 +337,12 @@ func TestGossipMostDistant(t *testing.T) { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) - connect := func(from, to *Gossip) { + connect := func(from, to *Gossip, fromCtx *rpc.Context) { to.mu.Lock() addr := to.mu.is.NodeAddr to.mu.Unlock() from.mu.Lock() - from.startClientLocked(addr) + from.startClientLocked(addr, fromCtx) from.mu.Unlock() } @@ -382,12 +373,13 @@ func TestGossipMostDistant(t *testing.T) { // // 1 <- 2 <- 3 <- 4 <- 5 <- 6 <- 7 <- 8 <- 9 <- 10 nodes := make([]*Gossip, n) + nodesCtx := make([]*rpc.Context, n) for i := range nodes { - nodes[i] = startGossip(clusterID, roachpb.NodeID(i+1), stopper, t, metric.NewRegistry()) + nodes[i], nodesCtx[i] = startGossip(clusterID, roachpb.NodeID(i+1), stopper, t, metric.NewRegistry()) if i == 0 { continue } - connect(nodes[i], nodes[i-1]) + connect(nodes[i], nodes[i-1], nodesCtx[i]) } // Wait for n1 to determine that n10 is the most distant node. @@ -418,7 +410,7 @@ func TestGossipMostDistant(t *testing.T) { // Connect the network in a loop. This will cut the distance to the most // distant node in half. log.Infof(context.Background(), "connecting from n%d to n%d", c.from, c.to) - connect(nodes[c.from], nodes[c.to]) + connect(nodes[c.from], nodes[c.to], nodesCtx[c.from]) // Wait for n1 to determine that n6 is now the most distant hops from 9 // to 5 and change the most distant node to n6. @@ -470,7 +462,7 @@ func TestGossipNoForwardSelf(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -478,18 +470,22 @@ func TestGossipNoForwardSelf(t *testing.T) { // Start one loopback client plus enough additional clients to fill the // incoming clients. peers := []*Gossip{local} + peerCtx := []*rpc.Context{localCtx} + local.server.mu.Lock() maxSize := local.server.mu.incoming.maxSize local.server.mu.Unlock() for i := 0; i < maxSize; i++ { - peers = append(peers, startGossip(clusterID, roachpb.NodeID(i+2), stopper, t, metric.NewRegistry())) + g, gCtx := startGossip(clusterID, roachpb.NodeID(i+2), stopper, t, metric.NewRegistry()) + peers = append(peers, g) + peerCtx = append(peerCtx, gCtx) } - for _, peer := range peers { + for i, peer := range peers { c := newClient(log.MakeTestingAmbientCtxWithNewTracer(), local.GetNodeAddr(), makeMetrics()) testutils.SucceedsSoon(t, func() error { - conn, err := peer.rpcContext.GRPCUnvalidatedDial(c.addr.String()).Connect(ctx) + conn, err := peerCtx[i].GRPCUnvalidatedDial(c.addr.String()).Connect(ctx) if err != nil { return err } @@ -518,13 +514,13 @@ func TestGossipNoForwardSelf(t *testing.T) { local.server.mu.Lock() maxSize := local.server.mu.incoming.maxSize local.server.mu.Unlock() - peer := startGossip(clusterID, roachpb.NodeID(i+maxSize+2), stopper, t, metric.NewRegistry()) + peer, peerCtx := startGossip(clusterID, roachpb.NodeID(i+maxSize+2), stopper, t, metric.NewRegistry()) for { localAddr := local.GetNodeAddr() c := newClient(log.MakeTestingAmbientCtxWithNewTracer(), localAddr, makeMetrics()) peer.mu.Lock() - c.startLocked(peer, disconnectedCh, peer.rpcContext, stopper, peer.rpcContext.NewBreaker("")) + c.startLocked(peer, disconnectedCh, peerCtx, stopper, peerCtx.NewBreaker("")) peer.mu.Unlock() disconnectedClient := <-disconnectedCh @@ -555,13 +551,13 @@ func TestGossipCullNetwork(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) local.SetCullInterval(5 * time.Millisecond) local.mu.Lock() for i := 0; i < minPeers; i++ { - peer := startGossip(clusterID, roachpb.NodeID(i+2), stopper, t, metric.NewRegistry()) - local.startClientLocked(*peer.GetNodeAddr()) + peer, peerCtx := startGossip(clusterID, roachpb.NodeID(i+2), stopper, t, metric.NewRegistry()) + local.startClientLocked(*peer.GetNodeAddr(), peerCtx) } local.mu.Unlock() @@ -576,7 +572,7 @@ func TestGossipCullNetwork(t *testing.T) { t.Fatalf("condition failed to evaluate within %s: %s", slowGossipDuration, err) } - local.manage() + local.manage(localCtx) if err := retry.ForDuration(slowGossipDuration, func() error { // Verify that a client is closed within the cull interval. @@ -599,7 +595,7 @@ func TestGossipOrphanedStallDetection(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) local.SetStallInterval(5 * time.Millisecond) // Make sure we have the sentinel to ensure that its absence is not the @@ -609,14 +605,14 @@ func TestGossipOrphanedStallDetection(t *testing.T) { } peerStopper := stop.NewStopper() - peer := startGossip(clusterID, 2, peerStopper, t, metric.NewRegistry()) + peer, _ := startGossip(clusterID, 2, peerStopper, t, metric.NewRegistry()) peerNodeID := peer.NodeID.Get() peerAddr := peer.GetNodeAddr() peerAddrStr := peerAddr.String() local.mu.Lock() - local.startClientLocked(*peerAddr) + local.startClientLocked(*peerAddr, localCtx) local.mu.Unlock() testutils.SucceedsSoon(t, func() error { @@ -637,8 +633,8 @@ func TestGossipOrphanedStallDetection(t *testing.T) { return errors.Errorf("n%d descriptor not yet available", peerNodeID) }) - local.bootstrap() - local.manage() + local.bootstrap(localCtx) + local.manage(localCtx) peerStopper.Stop(context.Background()) @@ -713,8 +709,8 @@ func TestGossipJoinTwoClusters(t *testing.T) { server := rpc.NewServer(rpcContext) // node ID must be non-zero - gnode := NewTest( - roachpb.NodeID(i+1), rpcContext, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + gnode := NewTest(roachpb.NodeID(i+1), stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + RegisterGossipServer(server, gnode) g = append(g, gnode) gnode.SetStallInterval(interval) gnode.SetBootstrapInterval(interval) @@ -734,7 +730,7 @@ func TestGossipJoinTwoClusters(t *testing.T) { addresses = append(addresses, util.MakeUnresolvedAddr("tcp", addrs[j].String())) } } - gnode.Start(ln.Addr(), addresses) + gnode.Start(ln.Addr(), addresses, rpcContext) } // Wait for connections. @@ -779,13 +775,13 @@ func TestGossipPropagation(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) - remote := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + remote, remoteCtx := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) remote.mu.Lock() rAddr := remote.mu.is.NodeAddr remote.mu.Unlock() - local.manage() - remote.manage() + local.manage(localCtx) + remote.manage(remoteCtx) mustAdd := func(g *Gossip, key string, val []byte, ttl time.Duration) { if err := g.AddInfo(key, val, ttl); err != nil { @@ -802,7 +798,7 @@ func TestGossipPropagation(t *testing.T) { // Restart the client connection in the loop. It might have failed due to // a heartbeat timeout. local.mu.Lock() - local.startClientLocked(rAddr) + local.startClientLocked(rAddr, localCtx) local.mu.Unlock() return fmt.Errorf("unable to find local to remote client") } @@ -895,13 +891,13 @@ func TestGossipLoopbackInfoPropagation(t *testing.T) { // don't talk to servers from unrelated tests by accident). clusterID := uuid.MakeV4() - local := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) - remote := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) + local, localCtx := startGossip(clusterID, 1, stopper, t, metric.NewRegistry()) + remote, remoteCtx := startGossip(clusterID, 2, stopper, t, metric.NewRegistry()) remote.mu.Lock() rAddr := remote.mu.is.NodeAddr remote.mu.Unlock() - local.manage() - remote.manage() + local.manage(localCtx) + remote.manage(remoteCtx) // Add a gossip info for "foo" on remote, that was generated by local. This // simulates what happens if local was to gossip an info, and later restart @@ -927,7 +923,7 @@ func TestGossipLoopbackInfoPropagation(t *testing.T) { // Start a client connection to the remote node. local.mu.Lock() - local.startClientLocked(rAddr) + local.startClientLocked(rAddr, localCtx) local.mu.Unlock() getInfo := func(g *Gossip, key string) *Info { diff --git a/pkg/gossip/simulation/network.go b/pkg/gossip/simulation/network.go index a41a0ba976bb..f239d5b00523 100644 --- a/pkg/gossip/simulation/network.go +++ b/pkg/gossip/simulation/network.go @@ -116,7 +116,8 @@ func (n *Network) CreateNode(defaultZoneConfig *zonepb.ZoneConfig) (*Node, error return nil, err } node := &Node{Server: server, Listener: ln, Registry: metric.NewRegistry()} - node.Gossip = gossip.NewTest(0, n.RPCContext, server, n.Stopper, node.Registry, defaultZoneConfig) + node.Gossip = gossip.NewTest(0, n.Stopper, node.Registry, defaultZoneConfig) + gossip.RegisterGossipServer(server, node.Gossip) n.Stopper.AddCloser(stop.CloserFn(server.Stop)) _ = n.Stopper.RunAsyncTask(context.TODO(), "node-wait-quiesce", func(context.Context) { <-n.Stopper.ShouldQuiesce() @@ -130,7 +131,7 @@ func (n *Network) CreateNode(defaultZoneConfig *zonepb.ZoneConfig) (*Node, error // StartNode initializes a gossip instance for the simulation node and // starts it. func (n *Network) StartNode(node *Node) error { - node.Gossip.Start(node.Addr(), node.Addresses) + node.Gossip.Start(node.Addr(), node.Addresses, n.RPCContext) node.Gossip.EnableSimulationCycler(true) n.nodeIDAllocator++ node.Gossip.NodeID.Set(context.TODO(), n.nodeIDAllocator) diff --git a/pkg/kv/bulk/sst_batcher.go b/pkg/kv/bulk/sst_batcher.go index 0588d606d9b0..daac3b217978 100644 --- a/pkg/kv/bulk/sst_batcher.go +++ b/pkg/kv/bulk/sst_batcher.go @@ -624,6 +624,7 @@ func (b *SSTBatcher) doFlush(ctx context.Context, reason int) error { b.mu.Lock() defer b.mu.Unlock() summary.DataSize += int64(size) + summary.SSTDataSize += int64(len(data)) currentBatchStatsCopy.DataSize += int64(size) b.mu.totalRows.Add(summary) diff --git a/pkg/kv/kvclient/kvcoord/dist_sender_test.go b/pkg/kv/kvclient/kvcoord/dist_sender_test.go index cf603c60f2f2..5ee31b08d402 100644 --- a/pkg/kv/kvclient/kvcoord/dist_sender_test.go +++ b/pkg/kv/kvclient/kvcoord/dist_sender_test.go @@ -212,10 +212,8 @@ func (l *simpleTransportAdapter) MoveToFront(replica roachpb.ReplicaDescriptor) func (l *simpleTransportAdapter) Release() {} func makeGossip(t *testing.T, stopper *stop.Stopper, rpcContext *rpc.Context) *gossip.Gossip { - server := rpc.NewServer(rpcContext) - const nodeID = 1 - g := gossip.NewTest(nodeID, rpcContext, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := gossip.NewTest(nodeID, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) if err := g.SetNodeDescriptor(newNodeDesc(nodeID)); err != nil { t.Fatal(err) } diff --git a/pkg/kv/kvserver/allocator/allocatorimpl/BUILD.bazel b/pkg/kv/kvserver/allocator/allocatorimpl/BUILD.bazel index 3a42e335d0bf..b8053a68bacb 100644 --- a/pkg/kv/kvserver/allocator/allocatorimpl/BUILD.bazel +++ b/pkg/kv/kvserver/allocator/allocatorimpl/BUILD.bazel @@ -42,7 +42,6 @@ go_test( args = ["-test.timeout=295s"], embed = [":allocatorimpl"], deps = [ - "//pkg/base", "//pkg/config/zonepb", "//pkg/gossip", "//pkg/keys", @@ -53,7 +52,6 @@ go_test( "//pkg/kv/kvserver/liveness/livenesspb", "//pkg/kv/kvserver/replicastats", "//pkg/roachpb", - "//pkg/rpc", "//pkg/settings/cluster", "//pkg/testutils", "//pkg/testutils/gossiputil", diff --git a/pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go b/pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go index 185aef65d313..0fae23a78fed 100644 --- a/pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go +++ b/pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go @@ -22,7 +22,6 @@ import ( "testing" "time" - "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/config/zonepb" "github.com/cockroachdb/cockroach/pkg/gossip" "github.com/cockroachdb/cockroach/pkg/keys" @@ -33,7 +32,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb" "github.com/cockroachdb/cockroach/pkg/kv/kvserver/replicastats" "github.com/cockroachdb/cockroach/pkg/roachpb" - "github.com/cockroachdb/cockroach/pkg/rpc" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/gossiputil" @@ -8205,18 +8203,7 @@ func TestAllocatorFullDisks(t *testing.T) { tr := tracing.NewTracer() clock := hlc.NewClockWithSystemTimeSource(time.Nanosecond /* maxOffset */) - // Model a set of stores in a cluster doing rebalancing, with ranges being - // randomly added occasionally. - rpcContext := rpc.NewContext(ctx, rpc.ContextOptions{ - TenantID: roachpb.SystemTenantID, - Config: &base.Config{Insecure: true}, - Clock: clock.WallClock(), - MaxOffset: clock.MaxOffset(), - Stopper: stopper, - Settings: st, - }) - server := rpc.NewServer(rpcContext) // never started - g := gossip.NewTest(1, rpcContext, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := gossip.NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) storepool.TimeUntilStoreDead.Override(ctx, &st.SV, storepool.TestTimeUntilStoreDeadOff) @@ -8661,16 +8648,7 @@ func exampleRebalancing( // Model a set of stores in a cluster, // adding / rebalancing ranges of random sizes. - rpcContext := rpc.NewContext(ctx, rpc.ContextOptions{ - TenantID: roachpb.SystemTenantID, - Config: &base.Config{Insecure: true}, - Clock: clock.WallClock(), - MaxOffset: clock.MaxOffset(), - Stopper: stopper, - Settings: st, - }) - server := rpc.NewServer(rpcContext) // never started - g := gossip.NewTest(1, rpcContext, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := gossip.NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) storepool.TimeUntilStoreDead.Override(ctx, &st.SV, storepool.TestTimeUntilStoreDeadOff) diff --git a/pkg/kv/kvserver/allocator/storepool/BUILD.bazel b/pkg/kv/kvserver/allocator/storepool/BUILD.bazel index 0868601ecac7..6e1fdfbb5560 100644 --- a/pkg/kv/kvserver/allocator/storepool/BUILD.bazel +++ b/pkg/kv/kvserver/allocator/storepool/BUILD.bazel @@ -11,7 +11,6 @@ go_library( importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/storepool", visibility = ["//visibility:public"], deps = [ - "//pkg/base", "//pkg/config/zonepb", "//pkg/gossip", "//pkg/kv/kvserver/allocator", @@ -19,7 +18,6 @@ go_library( "//pkg/kv/kvserver/liveness", "//pkg/kv/kvserver/liveness/livenesspb", "//pkg/roachpb", - "//pkg/rpc", "//pkg/settings", "//pkg/settings/cluster", "//pkg/util", diff --git a/pkg/kv/kvserver/allocator/storepool/test_helpers.go b/pkg/kv/kvserver/allocator/storepool/test_helpers.go index 4effe9240eff..160a0c7dd0fd 100644 --- a/pkg/kv/kvserver/allocator/storepool/test_helpers.go +++ b/pkg/kv/kvserver/allocator/storepool/test_helpers.go @@ -14,12 +14,10 @@ import ( "context" "time" - "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/config/zonepb" "github.com/cockroachdb/cockroach/pkg/gossip" "github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb" "github.com/cockroachdb/cockroach/pkg/roachpb" - "github.com/cockroachdb/cockroach/pkg/rpc" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/util/hlc" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -81,17 +79,7 @@ func CreateTestStorePool( mc := timeutil.NewManualTime(timeutil.Unix(0, 123)) clock := hlc.NewClock(mc, time.Nanosecond /* maxOffset */) ambientCtx := log.MakeTestingAmbientContext(stopper.Tracer()) - rpcContext := rpc.NewContext(ctx, - rpc.ContextOptions{ - TenantID: roachpb.SystemTenantID, - Config: &base.Config{Insecure: true}, - Clock: clock.WallClock(), - MaxOffset: clock.MaxOffset(), - Stopper: stopper, - Settings: st, - }) - server := rpc.NewServer(rpcContext) // never started - g := gossip.NewTest(1, rpcContext, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := gossip.NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) mnl := NewMockNodeLiveness(defaultNodeStatus) TimeUntilStoreDead.Override(ctx, &st.SV, timeUntilStoreDeadValue) diff --git a/pkg/kv/kvserver/asim/state/helpers.go b/pkg/kv/kvserver/asim/state/helpers.go index 24f589dc2688..00cac1f969c3 100644 --- a/pkg/kv/kvserver/asim/state/helpers.go +++ b/pkg/kv/kvserver/asim/state/helpers.go @@ -73,7 +73,7 @@ func NewStorePool( ambientCtx := log.MakeTestingAmbientContext(stopper.Tracer()) // Never gossip, pass in nil values. - g := gossip.NewTest(1, nil, nil, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := gossip.NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) sp := storepool.NewStorePool( ambientCtx, st, diff --git a/pkg/kv/kvserver/raft_transport_test.go b/pkg/kv/kvserver/raft_transport_test.go index 7cbb12d95177..380c741bdfde 100644 --- a/pkg/kv/kvserver/raft_transport_test.go +++ b/pkg/kv/kvserver/raft_transport_test.go @@ -140,10 +140,7 @@ func newRaftTransportTestContext(t testing.TB) *raftTransportTestContext { // we can't enforce some of the RPC check validation. rttc.nodeRPCContext.TestingAllowNamedRPCToAnonymousServer = true - server := rpc.NewServer(rttc.nodeRPCContext) // never started - rttc.gossip = gossip.NewTest( - 1, rttc.nodeRPCContext, server, rttc.stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef(), - ) + rttc.gossip = gossip.NewTest(1, rttc.stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) return rttc } diff --git a/pkg/kv/kvserver/store_test.go b/pkg/kv/kvserver/store_test.go index d3bf9b0f846a..40becaaee644 100644 --- a/pkg/kv/kvserver/store_test.go +++ b/pkg/kv/kvserver/store_test.go @@ -193,7 +193,7 @@ func createTestStoreWithoutStart( // TestChooseLeaseToTransfer and TestNoLeaseTransferToBehindReplicas. This is // generally considered bad and should eventually be refactored away. if cfg.Gossip == nil { - cfg.Gossip = gossip.NewTest(1, rpcContext, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + cfg.Gossip = gossip.NewTest(1, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) } if cfg.StorePool == nil { cfg.StorePool = NewTestStorePool(*cfg) diff --git a/pkg/roachpb/api.go b/pkg/roachpb/api.go index de4007ae24ed..cb672fc580e1 100644 --- a/pkg/roachpb/api.go +++ b/pkg/roachpb/api.go @@ -1470,6 +1470,7 @@ func BulkOpSummaryID(tableID, indexID uint64) uint64 { // Add combines the values from other, for use on an accumulator BulkOpSummary. func (b *BulkOpSummary) Add(other BulkOpSummary) { b.DataSize += other.DataSize + b.SSTDataSize += other.SSTDataSize b.DeprecatedRows += other.DeprecatedRows b.DeprecatedIndexEntries += other.DeprecatedIndexEntries diff --git a/pkg/roachpb/api.proto b/pkg/roachpb/api.proto index 59b8c183380b..19556653ee48 100644 --- a/pkg/roachpb/api.proto +++ b/pkg/roachpb/api.proto @@ -1641,6 +1641,8 @@ message ExportRequest { message BulkOpSummary { // DataSize is the sum of key and value lengths. int64 data_size = 1; + // SSTDataSize is the size of the SST, post compression, sent to KV. + int64 sst_data_size = 6 [(gogoproto.customname) = "SSTDataSize"]; // DeprecatedRows contained the row count when "rows" were always defined as // entries in the index with ID 1, however since 20.1 and the introduction of // PK changes, the low-level counters that produce BulkOpSummaries are unable diff --git a/pkg/server/server.go b/pkg/server/server.go index 7853b280df8c..0196687970b5 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -260,6 +260,16 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) { nodeTombStorage, checkPingFor := getPingCheckDecommissionFn(engines) + g := gossip.New( + cfg.AmbientCtx, + cfg.ClusterIDContainer, + nodeIDContainer, + stopper, + registry, + cfg.Locality, + &cfg.DefaultZoneConfig, + ) + rpcCtxOpts := rpc.ContextOptions{ TenantID: roachpb.SystemTenantID, NodeID: cfg.IDContainer, @@ -329,18 +339,7 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) { rpcContext.CheckCertificateAddrs(ctx) grpcServer := newGRPCServer(rpcContext) - - g := gossip.New( - cfg.AmbientCtx, - rpcContext.StorageClusterID, - nodeIDContainer, - rpcContext, - grpcServer.Server, - stopper, - registry, - cfg.Locality, - &cfg.DefaultZoneConfig, - ) + gossip.RegisterGossipServer(grpcServer.Server, g) var dialerKnobs nodedialer.DialerTestingKnobs if dk := cfg.TestingKnobs.DialerKnobs; dk != nil { @@ -1583,7 +1582,7 @@ func (s *Server) PreStart(ctx context.Context) error { advAddrU := util.NewUnresolvedAddr("tcp", s.cfg.AdvertiseAddr) // We're going to need to start gossip before we spin up Node below. - s.gossip.Start(advAddrU, filtered) + s.gossip.Start(advAddrU, filtered, s.rpcContext) log.Event(ctx, "started gossip") // Now that we have a monotonic HLC wrt previous incarnations of the process, diff --git a/pkg/sql/distsql_physical_planner_test.go b/pkg/sql/distsql_physical_planner_test.go index d2f9f7f68bb1..15c208d681bb 100644 --- a/pkg/sql/distsql_physical_planner_test.go +++ b/pkg/sql/distsql_physical_planner_test.go @@ -791,8 +791,7 @@ func TestPartitionSpans(t *testing.T) { // DistSQLPlanner will not plan flows on them. testStopper := stop.NewStopper() defer testStopper.Stop(context.Background()) - mockGossip := gossip.NewTest(roachpb.NodeID(1), nil /* rpcContext */, nil, /* grpcServer */ - testStopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + mockGossip := gossip.NewTest(roachpb.NodeID(1), testStopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) var nodeDescs []*roachpb.NodeDescriptor for i := 1; i <= 10; i++ { sqlInstanceID := base.SQLInstanceID(i) @@ -987,8 +986,7 @@ func TestPartitionSpansSkipsIncompatibleNodes(t *testing.T) { // reflect tc.nodesNotAdvertisingDistSQLVersion. testStopper := stop.NewStopper() defer testStopper.Stop(context.Background()) - mockGossip := gossip.NewTest(roachpb.NodeID(1), nil /* rpcContext */, nil, /* grpcServer */ - testStopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + mockGossip := gossip.NewTest(roachpb.NodeID(1), testStopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) var nodeDescs []*roachpb.NodeDescriptor for i := 1; i <= 2; i++ { sqlInstanceID := base.SQLInstanceID(i) @@ -1082,8 +1080,7 @@ func TestPartitionSpansSkipsNodesNotInGossip(t *testing.T) { stopper := stop.NewStopper() defer stopper.Stop(context.Background()) - mockGossip := gossip.NewTest(roachpb.NodeID(1), nil /* rpcContext */, nil, /* grpcServer */ - stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + mockGossip := gossip.NewTest(roachpb.NodeID(1), stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) var nodeDescs []*roachpb.NodeDescriptor for i := 1; i <= 2; i++ { sqlInstanceID := base.SQLInstanceID(i) @@ -1178,7 +1175,7 @@ func TestCheckNodeHealth(t *testing.T) { const sqlInstanceID = base.SQLInstanceID(5) - mockGossip := gossip.NewTest(roachpb.NodeID(sqlInstanceID), nil /* rpcContext */, nil, /* grpcServer */ + mockGossip := gossip.NewTest(roachpb.NodeID(sqlInstanceID), stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) desc := &roachpb.NodeDescriptor{ diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index 334c9d79f92c..c95f09e7e5ec 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -1965,7 +1965,6 @@ alter_database_owner: alter_database_set_stmt: ALTER DATABASE database_name set_or_reset_clause { - /* SKIP DOC */ $$.val = &tree.AlterRoleSet{ AllRoles: true, DatabaseName: tree.Name($3), @@ -1977,7 +1976,6 @@ alter_database_set_stmt: alter_database_placement_stmt: ALTER DATABASE database_name placement_clause { - /* SKIP DOC */ $$.val = &tree.AlterDatabasePlacement{ Name: tree.Name($3), Placement: $4.dataPlacement(), @@ -11156,12 +11154,10 @@ opt_placement_clause: placement_clause: PLACEMENT RESTRICTED { - /* SKIP DOC */ $$.val = tree.DataPlacementRestricted } | PLACEMENT DEFAULT { - /* SKIP DOC */ $$.val = tree.DataPlacementDefault } diff --git a/pkg/sql/physicalplan/replicaoracle/BUILD.bazel b/pkg/sql/physicalplan/replicaoracle/BUILD.bazel index f09d0774bc7b..3f0de494476b 100644 --- a/pkg/sql/physicalplan/replicaoracle/BUILD.bazel +++ b/pkg/sql/physicalplan/replicaoracle/BUILD.bazel @@ -29,7 +29,6 @@ go_test( "//pkg/config/zonepb", "//pkg/gossip", "//pkg/roachpb", - "//pkg/rpc", "//pkg/testutils", "//pkg/util", "//pkg/util/hlc", diff --git a/pkg/sql/physicalplan/replicaoracle/oracle_test.go b/pkg/sql/physicalplan/replicaoracle/oracle_test.go index 1cce2c93e815..d52d57f02478 100644 --- a/pkg/sql/physicalplan/replicaoracle/oracle_test.go +++ b/pkg/sql/physicalplan/replicaoracle/oracle_test.go @@ -21,7 +21,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/config/zonepb" "github.com/cockroachdb/cockroach/pkg/gossip" "github.com/cockroachdb/cockroach/pkg/roachpb" - "github.com/cockroachdb/cockroach/pkg/rpc" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/hlc" @@ -85,12 +84,9 @@ func TestClosest(t *testing.T) { func makeGossip(t *testing.T, stopper *stop.Stopper) (*gossip.Gossip, *hlc.Clock) { clock := hlc.NewClockWithSystemTimeSource(time.Nanosecond /* maxOffset */) - ctx := context.Background() - rpcContext := rpc.NewInsecureTestingContext(ctx, clock, stopper) - server := rpc.NewServer(rpcContext) const nodeID = 1 - g := gossip.NewTest(nodeID, rpcContext, server, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) + g := gossip.NewTest(nodeID, stopper, metric.NewRegistry(), zonepb.DefaultZoneConfigRef()) if err := g.SetNodeDescriptor(newNodeDesc(nodeID)); err != nil { t.Fatal(err) } diff --git a/pkg/testutils/localtestcluster/local_test_cluster.go b/pkg/testutils/localtestcluster/local_test_cluster.go index 7683056c3760..d0fbe307886f 100644 --- a/pkg/testutils/localtestcluster/local_test_cluster.go +++ b/pkg/testutils/localtestcluster/local_test_cluster.go @@ -145,8 +145,7 @@ func (ltc *LocalTestCluster) Start(t testing.TB, baseCtx *base.Config, initFacto }) cfg.RPCContext.NodeID.Set(ctx, nodeID) clusterID := cfg.RPCContext.StorageClusterID - server := rpc.NewServer(cfg.RPCContext) // never started - ltc.Gossip = gossip.New(ambient, clusterID, nc, cfg.RPCContext, server, ltc.stopper, metric.NewRegistry(), roachpb.Locality{}, zonepb.DefaultZoneConfigRef()) + ltc.Gossip = gossip.New(ambient, clusterID, nc, ltc.stopper, metric.NewRegistry(), roachpb.Locality{}, zonepb.DefaultZoneConfigRef()) var err error ltc.Eng, err = storage.Open( ctx, diff --git a/pkg/ts/catalog/chart_catalog.go b/pkg/ts/catalog/chart_catalog.go index a72d8c93cc53..e6fd8c5a2d19 100644 --- a/pkg/ts/catalog/chart_catalog.go +++ b/pkg/ts/catalog/chart_catalog.go @@ -1619,6 +1619,12 @@ var charts = []sectionDescription{ "streaming.ingested_bytes", }, }, + { + Title: "SST Bytes", + Metrics: []string{ + "streaming.sst_bytes", + }, + }, { Title: "Earliest Data Processor Checkpoint Span", Metrics: []string{"streaming.earliest_data_checkpoint_span"},