forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: pre-split hash sharded indexes ranges before DELETE_AND_WRITE_ONLY
Fixes cockroachdb#74558 Pre-split ranges on shard boundaries before SchemaChanger move new hash sharded indexes from DELETE_ONLY to DELETE_AND_WRITE_ONLY state. Release note (bug fix): When creating hash sharded index to an existing table, traffic could hit hard on the single range of the index before it is split into more ranges for shards as range size grows. This change make schema changer able to presplit ranges on shard boundaries before the index becomes writable. `sql.hash_sharded_range_pre_split.max` is the cluster setting added so that users can set the upbound of the amount of ranges to have. If the bucket count of the defined index is less than the cluster setting, the bucket count will be the amount of pre-split ranges.
- Loading branch information
1 parent
f479a04
commit 40a9206
Showing
6 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
pkg/sql/logictest/testdata/logic_test/hash_sharded_index_presplit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# AdminSplit is not allowed in multi-tenant. | ||
# LogicTest: !3node-tenant | ||
|
||
statement ok | ||
SET experimental_enable_hash_sharded_indexes = on; | ||
CREATE TABLE t_hash_pre_split ( | ||
a INT PRIMARY KEY, | ||
b INT | ||
); | ||
|
||
query TITTT retry | ||
SELECT t.name, r.table_id, r.index_name, r.start_pretty, r.end_pretty | ||
FROM crdb_internal.tables t | ||
JOIN crdb_internal.ranges r ON t.table_id = r.table_id | ||
WHERE t.name = 't_hash_pre_split' | ||
AND t.state = 'PUBLIC' | ||
AND r.split_enforced_until IS NOT NULL; | ||
---- | ||
|
||
statement ok | ||
CREATE INDEX t_hash_pre_split_idx_b ON t_hash_pre_split (b) USING HASH WITH BUCKET_COUNT = 8; | ||
|
||
query TITTT colnames,retry | ||
SELECT t.name, r.table_id, r.index_name, r.start_pretty, r.end_pretty | ||
FROM crdb_internal.tables t | ||
JOIN crdb_internal.ranges r ON t.table_id = r.table_id | ||
WHERE t.name = 't_hash_pre_split' | ||
AND t.state = 'PUBLIC' | ||
AND r.split_enforced_until IS NOT NULL; | ||
---- | ||
name table_id index_name start_pretty end_pretty | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2 /Table/92/2/0 | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2/0 /Table/92/2/1 | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2/1 /Table/92/2/2 | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2/2 /Table/92/2/3 | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2/3 /Table/92/2/4 | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2/4 /Table/92/2/5 | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2/5 /Table/92/2/6 | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2/6 /Table/92/2/7 | ||
t_hash_pre_split 92 t_hash_pre_split_idx_b /Table/92/2/7 /Max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters