Commit ad88c428 authored by Sergei Petrunia's avatar Sergei Petrunia

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)
parent d3143ef8
......@@ -6668,6 +6668,17 @@ int ha_rocksdb::open(const char *const name, int mode, uint test_if_locked) {
"dictionary");
DBUG_RETURN(HA_ERR_ROCKSDB_INVALID_TABLE);
}
if (m_tbl_def->m_key_count != table->s->keys + has_hidden_pk(table)? 1:0)
{
sql_print_error("MyRocks: DDL mismatch: .frm file has %u indexes, "
"MyRocks has %u (%s hidden pk)",
table->s->keys, m_tbl_def->m_key_count,
has_hidden_pk(table)? "1" : "no");
my_error(ER_INTERNAL_ERROR, MYF(0),
"MyRocks: DDL mismatch. Check the error log for details");
DBUG_RETURN(HA_ERR_ROCKSDB_INVALID_TABLE);
}
m_lock_rows = RDB_LOCK_NONE;
m_key_descr_arr = m_tbl_def->m_key_descr_arr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment