yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.68k stars 1.04k forks source link

[DocDB] [Tablet Splitting] Automatic tablet splitting is not happening for the range indexes(which are restored from backup) #17169

Closed Arjun-yb closed 1 year ago

Arjun-yb commented 1 year ago

Jira Link: DB-6444

Description

Automatic tablet splitting is not happening for the range indexes(which are restored from backup)

Version: 2.18.0.0-b31

Steps:

  1. Create universe in 2.8.12
  2. Create tables and indexes(hash and range)
    
    CREATE DATABASE backup_restore_ysql_db;

CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TYPE complex AS (re float8, im float8); CREATE DOMAIN postal_code AS TEXT CHECK(VALUE ~ '^\d{5}$'OR VALUE ~ '^\d{5}-\d{4}$'); CREATE TYPE e_details AS ENUM ('Email', 'Sms', 'Phone');

CREATE TABLE bkup_restore_ysql_table_hash(id text, uuid_col uuid DEFAULT uuid_generate_v4 (), name text, c complex, info json, contact JSONB, arr smallint[], cash money, i inet, m macaddr, i2 serial, i3 bigserial, val smallint, details e_details, age int, collated_data text, date DATE, n NUMERIC (3, 2), r real, c1 CHAR(1), created_at timestamptz, uuid0 uuid DEFAULT uuid_nil(), uuid1 uuid DEFAULT uuid_generate_v1(), p1 POINT, t1 TIME, ts1 TIMESTAMP, i4 INTERVAL, p2 path, p3 polygon, b box, c2 circle, l line, l1 lseg, a2 text[][], zip postal_code, PRIMARY KEY(id));

CREATE TABLE bkup_restore_ysql_table_range(id text, uuid_col uuid DEFAULT uuid_generate_v4 (), name text, c complex, info json, contact JSONB, arr smallint[], cash money, i inet, m macaddr, i2 serial, i3 bigserial, val smallint, details e_details, age int, collated_data text, date DATE, n NUMERIC (3, 2), r real, c1 CHAR(1), created_at timestamptz, uuid0 uuid DEFAULT uuid_nil(), uuid1 uuid DEFAULT uuid_generate_v1(), p1 POINT, t1 TIME, ts1 TIMESTAMP, i4 INTERVAL, p2 path, p3 polygon, b box, c2 circle, l line, l1 lseg, a2 text[][], zip postal_code, PRIMARY KEY(id ASC));

CREATE INDEX hash_table_range_secondary_idx ON bkup_restore_ysql_table_hash(name ASC); CREATE UNIQUE INDEX hash_table_range_unique_idx ON bkup_restore_ysql_table_hash(name ASC, age DESC, created_at ASC); CREATE INDEX hash_table_hash_partial_idx ON bkup_restore_ysql_table_hash(name, age, uuid_col) WHERE age>10;

CREATE INDEX range_table_hash_secondary_idx ON bkup_restore_ysql_table_range(name); CREATE UNIQUE INDEX range_table_hash_unique_idx ON bkup_restore_ysql_table_range(name, age, created_at); CREATE INDEX range_table_range_partial_idx ON bkup_restore_ysql_table_range(name ASC, age DESC, uuid_col DESC) WHERE age>10;

3. Load 100K rows and take backup
4. Create universe in 2.18 with below GFLAGs
**Master**:

{ "enable_automatic_tablet_splitting": "true", "tablet_split_high_phase_shard_count_per_node": 500, "tablet_split_high_phase_size_threshold_bytes": 51200, "tablet_split_low_phase_size_threshold_bytes": 5120, "tablet_split_low_phase_shard_count_per_node": 16, "tablet_split_limit_per_table": 512, "enable_stream_compression": "true", "stream_compression_algo": 3, "ysql_enable_packed_row": "true" }

**Tserver**:

{ "enable_automatic_tablet_splitting": "true", "yb_num_shards_per_tserver": 1, "ysql_num_shards_per_tserver": 1, "enable_stream_compression": "true", "stream_compression_algo": 3, "scheduled_full_compaction_frequency_hours": "12", "scheduled_full_compaction_jitter_factor_percentage": "100", "scheduled_full_compaction_check_interval_min": "5", "ysql_enable_packed_row": "true" }


5. Restore backup in 2.18 universe and check the tablets of tables and indexes

**Observations**:
1. Tablets splitting is not happing for range indexes(which are restored from the backup)
2. Splitting is not happening even if we load some more data to the tables.
3. If user creates new range indexes(with same schema as is previous range indexes) tablet splitting is happening for the newly created range indexes.

### Warning: Please confirm that this issue does not contain any sensitive information

- [X] I confirm this issue does not contain any sensitive information.

[DB-6444]: https://yugabyte.atlassian.net/browse/DB-6444?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
arybochkin commented 1 year ago

This is an expected behaviour for the backups taken before 2.14.5.0-b8 as this is the earliest release which contains the fix that supports partition key corrected algo and partition key version parameter. If the backup is taken before 2.14.5.0-b8 and is restored to any release ≥ 2.14.5.0-b8 then tablet splitting for range-partitioned index tables is disabled for restored index tables to avoid data inconsistency. Newly created index tables are fine with tablet splitting (an partitioning_version is set to 1 for them). @Arjun-yb, the issue can be closed but if you want you may re-check with a backup from a build ≥ 2.14.5.0-b8. I believe this was tested a lot of times already.

Arjun-yb commented 1 year ago

Closing this as it is expected behaviour with older version's backup