From 7a59acf2485d21b87f67a7ed7a72d0ea80bc5582 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Thu, 23 Nov 2023 00:29:28 +0100 Subject: [PATCH] tablets: Fail gracefully when migrating tablet has no pending replica Before the patch we SIGSEGV trying to access pending replica in this case. Fail early instead. --- replica/tablets.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/replica/tablets.cc b/replica/tablets.cc index e2f4c2cbfd..33ba821b7a 100644 --- a/replica/tablets.cc +++ b/replica/tablets.cc @@ -213,6 +213,10 @@ future read_tablet_metadata(cql3::query_processor& qp) { for (auto&& r : tablet_replicas) { pending.erase(r); } + if (pending.size() == 0) { + throw std::runtime_error(format("Stage set but no pending replica for table {} tablet {}", + table, current->tid)); + } if (pending.size() > 1) { throw std::runtime_error(format("Too many pending replicas for table {} tablet {}: {}", table, current->tid, pending));