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.
  • Add the rocksdb.recovery_after_alter_crash MTR test, which simulates a server crash during an ALTER TABLE … ADD INDEX operation, detects a corrupted table definition, and verifies automatic recovery.


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 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a good idea, implemented.

@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
@inikep inikep changed the base branch from release-8.0.44-35 to 8.0 December 5, 2025 10:41
…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.
- Add the `rocksdb.recovery_after_alter_crash` MTR test, which simulates a server crash
  during an `ALTER TABLE … ADD INDEX` operation, detects a corrupted table definition,
  and verifies automatic recovery.
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