Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Fix server restart failure with binary log enabled
Browse files Browse the repository at this point in the history
Summary:
During startup, the data dictionary scans through a set of keys to find
the table names. These keys use the index prefix, which is 4 bytes. The
scanner knows it has hit the end of the list when the key it is
examining no longer matches the index prefix.

However, the scanner first verifies the length of the key is larger than
the index prefix before determining if the key is a data dictionary key.
If this key is not a data dictionary, but is 4 bytes (like the binlog
key), then it returns a failure and stops initialization.

Fix is to determine if the key has the index prefix before failing it
for invalid length.

Test Plan: running unit tests and added a new test

Reviewers: spetrunia, maykov, jonahcohen, yoshinorim

Reviewed By: yoshinorim

Differential Revision: https://reviews.facebook.net/D32481
  • Loading branch information
Herman Lee authored and jtolmer committed Jan 5, 2016
1 parent 3385295 commit 1fe66b5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions storage/rocksdb/rdb_datadic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -938,16 +938,17 @@ bool Table_ddl_manager::init(rocksdb::DB *rdb_dict)
rocksdb::Slice key= it->key();
rocksdb::Slice val= it->value();

if (key.size() >= RDBSE_KEYDEF::INDEX_NUMBER_SIZE &&
memcmp(key.data(), ddl_entry, RDBSE_KEYDEF::INDEX_NUMBER_SIZE))
break;

if (key.size() <= RDBSE_KEYDEF::INDEX_NUMBER_SIZE)
{
sql_print_error("RocksDB: Table_store: key has length %d (corruption?)",
(int)key.size());
return true;
}

if (memcmp(key.data(), ddl_entry, RDBSE_KEYDEF::INDEX_NUMBER_SIZE))
break;

RDBSE_TABLE_DEF *tdef= new RDBSE_TABLE_DEF;
tdef->dbname_tablename.append(key.data() + RDBSE_KEYDEF::INDEX_NUMBER_SIZE,
key.size() - RDBSE_KEYDEF::INDEX_NUMBER_SIZE);
Expand Down

0 comments on commit 1fe66b5

Please sign in to comment.