The yb_admin command get_table_hash will return the number of rows in each of its tablets, and the XOR hashes.
This command performs a Intent aware iteration (the same scan code used by YCQL and YSQL) to get the user visible data from the tablet.
- It works for both YSQL and YCQL tablets.
- It takes in an optional
read_htso that we can read the data as of a recent time in the past. -
To get the hash of the database, XOR the hashes of the tables in the database.
yb_admin get_table_hash <table_id> [read_ht]
Sample output:
Processing 2 tablets for table 000034d9000030008000000000004100
Read HT: { days: 20466 time: 16:22:26.258752 }
Tablet ID: 09bc4add191a47ff9dd858f84510195d
Row count: 5
XOR hash: 17016537574803746
Tablet ID: bc1800bdac7147c18d48f7d6dcc95feb
Row count: 5
XOR hash: 3475781051395342626
Total row count: 10
Total XOR hash: 3458764513820542976
NOTE: In order to use on large table without hitting read restart errors, user would have to increase timestamp_history_retention_interval_sec or setup Snapshot Schedules.
Minimum available versions:
2025.2.1, 2024.2.8, 2025.1.4
Use cases
This XOR hash can be used to verify the logical correctness in the following scenarios:
- Validate data consistency between xCluster universes (even when tablet counts are not the same)
- Validate correctness of Restore, PITR, CLONE
NOTE: To get the XOR hash of a single tablet peer (leader, or follower) use the yb_ts_cli dump_tablet_data command.
Comments
0 comments
Please sign in to leave a comment.