From be8445eea8ebf01a5e10ce40195636be41b275c1 Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Fri, 11 Sep 2020 07:55:00 -0700 Subject: [PATCH] Assert valid linked list for write group (#7375) Summary: We've seen some segfaults in db_write_test, with at least one suggesting corruption of a write group linked list. Adding an assertion to have this fail in a more specific way if that is the broken invariant. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7375 Test Plan: make check Reviewed By: jay-zhuang Differential Revision: D23638477 Pulled By: pdillinger fbshipit-source-id: a76fd677cad60a3a516bd363947bfd9ce418edc1 --- db/write_thread.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/write_thread.cc b/db/write_thread.cc index 36bda43fb..c74b7b0ed 100644 --- a/db/write_thread.cc +++ b/db/write_thread.cc @@ -438,6 +438,7 @@ size_t WriteThread::EnterAsBatchGroupLeader(Writer* leader, // (newest_writer) is inclusive. Iteration goes from old to new. Writer* w = leader; while (w != newest_writer) { + assert(w->link_newer); w = w->link_newer; if (w->sync && !leader->sync) { @@ -512,6 +513,7 @@ void WriteThread::EnterAsMemTableWriter(Writer* leader, Writer* w = leader; while (w != newest_writer) { + assert(w->link_newer); w = w->link_newer; if (w->batch == nullptr) { @@ -568,6 +570,7 @@ void WriteThread::ExitAsMemTableWriter(Writer* /*self*/, if (w == last_writer) { break; } + assert(next); w = next; } // Note that leader has to exit last, since it owns the write group. @@ -721,6 +724,7 @@ void WriteThread::ExitAsBatchGroupLeader(WriteGroup& write_group, // leader now while (last_writer != leader) { + assert(last_writer); last_writer->status = status; // we need to read link_older before calling SetState, because as soon // as it is marked committed the other thread's Await may return and