Skip to content

Conversation

@inikep
Copy link
Collaborator

@inikep inikep commented Nov 19, 2025

Add mechanisms to detect and recover corrupted table definitions (Rdb_tbl_def) in MyRocks after incomplete ALTER TABLE ... ADD INDEX operations.

  • Log detailed mismatch information between m_key_count and actual table keys, including the likely ALTER operation that caused it.
  • Introduce delete_table_def() to remove table definitions without touching table data.
  • Implement rebuild_table_def_from_table() to reconstruct corrupted Rdb_tbl_def by removing partially added indexes, preserving existing data.
  • Reduce verbosity of informational key logging from ERROR_LEVEL to INFORMATION_LEVEL.
  • Add optional automatic table validation/reconstruction controlled by rocksdb_validate_tables server variable.
  • Introduce rocksdb.recovery_after_alter_crash server variable to enable automatic detection and recovery of table definitions immediately after a crash during ALTER operations.

…n ALTER

Add mechanisms to detect and recover corrupted table definitions (`Rdb_tbl_def`) in MyRocks
after incomplete `ALTER TABLE ... ADD INDEX` operations.

- Log detailed mismatch information between `m_key_count` and actual table keys,
  including the likely ALTER operation that caused it.
- Introduce `delete_table_def()` to remove table definitions without touching table data.
- Implement `rebuild_table_def_from_table()` to reconstruct corrupted `Rdb_tbl_def` by
  removing partially added indexes, preserving existing data.
- Reduce verbosity of informational key logging from `ERROR_LEVEL` to `INFORMATION_LEVEL`.
- Add optional automatic table validation/reconstruction controlled by
  `rocksdb_validate_tables` server variable.
- Introduce `rocksdb.recovery_after_alter_crash` server variable to enable automatic detection
  and recovery of table definitions immediately after a crash during ALTER operations.

try {
new_key_descr = new std::shared_ptr<Rdb_key_def>[new_n_keys];
new_tdef = new Rdb_tbl_def(tbl_name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this allocation throws, we will have new_key_descr leaked.
May be use std::unique_ptr<Rdb_tbl_def> new_tdef and std::unique_ptr<Rdb_key_def[]> new_key_descr ?

@inikep inikep changed the title PS-10287 [8.0]: Add automatic table definition recovery after crash on ALTER PS-10324 [8.0]: Add automatic table definition recovery after crash on ALTER Nov 27, 2025
@inikep inikep changed the title PS-10324 [8.0]: Add automatic table definition recovery after crash on ALTER PS-10287 [8.0]: Add automatic table definition recovery after crash on ALTER Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants