Skip to content

Commit d125f5b

Browse files
jdduncandahlerlend
authored andcommitted
Bug#33342599 Mtr test ndb_bug17624736 crashes in Pb2
In ndb_sql_metadata_table.cc, fix where uninitialized memory was used a a search key for readTuple(), in initializeSnapshotLock(). Assert both there and in acquireSnapshotLock() that there is never an attempt to dereference a null NdbOperation pointer. Also clarify the comment there regarding the use case for __at_restart_skip_indexes. Reviewed-by: Mauritz Sundell <[email protected]>
1 parent 9aaacd5 commit d125f5b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

storage/ndb/plugin/ndb_sql_metadata_table.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,10 @@ void Ndb_sql_metadata_api::setup(NdbDictionary::Dictionary *dict,
150150
sizeof(m_record_layout.record_specs[0]));
151151

152152
const NdbDictionary::Index *primary = dict->getIndexGlobal("PRIMARY", *table);
153-
/* There is a test case where primary == nullptr because NDB has been
154-
configured with __at_restart_skip_indexes, and presumably there are also
155-
real-world data corruption situations where the table is available but
156-
the index is not. Do not handle those conditions here. They are detected
157-
later, when isInitialized() returns false.
153+
/* NDB can be started with __at_restart_skip_indexes as a one-time recovery
154+
measure in case of corruption. In this case, primary == nullptr.
155+
Do not handle that condition here; it is detected later by testing
156+
isInitialized().
158157
*/
159158
if (primary) {
160159
m_ordered_index_rec =
@@ -219,11 +218,12 @@ const NdbError &Ndb_sql_metadata_api::initializeSnapshotLock(Ndb *ndb) {
219218
err = &ndb->getNdbError();
220219
if (tx != nullptr) {
221220
const NdbOperation *read_op =
222-
tx->readTuple(keyNdbRecord(), row, noteNdbRecord(), row,
221+
tx->readTuple(keyNdbRecord(), key, noteNdbRecord(), row,
223222
NdbOperation::LM_CommittedRead);
224223
tx->execute(NoCommit);
225224

226-
if (read_op->getNdbError().code == 626) { // row not found
225+
assert(read_op);
226+
if (read_op && (read_op->getNdbError().code == 626)) { // row not found
227227
writeSnapshotLockRow(tx);
228228
tx->execute(Commit);
229229
}
@@ -264,7 +264,8 @@ const NdbError &Ndb_sql_metadata_api::acquireSnapshotLock(Ndb *ndb,
264264
tx->readTuple(keyNdbRecord(), key, noteNdbRecord(), row,
265265
NdbOperation::LM_Exclusive);
266266
tx->execute(NoCommit);
267-
if (read_op->getNdbError().code == 626) {
267+
assert(read_op);
268+
if (read_op && (read_op->getNdbError().code == 626)) {
268269
/* Someone has deleted the lock row, maybe using ndb_delete_all.
269270
Reinitialize the lock row and retry.
270271
*/

0 commit comments

Comments
 (0)