Skip to content

Commit ad88c42

Browse files
committed
Avoid a crash on MyRocks data inconsistency.
In ha_rocksdb::open(), check if the number of indexes seen from the SQL layer matches the number of indexes in the internal MyRocks data dictionary. Produce an error if there is a mismatch. (If we don't produce this error, we are likely to crash as soon as we attempt to use an index)
1 parent d3143ef commit ad88c42

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6668,6 +6668,17 @@ int ha_rocksdb::open(const char *const name, int mode, uint test_if_locked) {
66686668
"dictionary");
66696669
DBUG_RETURN(HA_ERR_ROCKSDB_INVALID_TABLE);
66706670
}
6671+
if (m_tbl_def->m_key_count != table->s->keys + has_hidden_pk(table)? 1:0)
6672+
{
6673+
sql_print_error("MyRocks: DDL mismatch: .frm file has %u indexes, "
6674+
"MyRocks has %u (%s hidden pk)",
6675+
table->s->keys, m_tbl_def->m_key_count,
6676+
has_hidden_pk(table)? "1" : "no");
6677+
my_error(ER_INTERNAL_ERROR, MYF(0),
6678+
"MyRocks: DDL mismatch. Check the error log for details");
6679+
DBUG_RETURN(HA_ERR_ROCKSDB_INVALID_TABLE);
6680+
}
6681+
66716682

66726683
m_lock_rows = RDB_LOCK_NONE;
66736684
m_key_descr_arr = m_tbl_def->m_key_descr_arr;

0 commit comments

Comments
 (0)