diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-27 18:36:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-27 18:36:49 +0200 |
commit | 1a380a5e64d2098e35c86d3bd83f88858875a18e (patch) | |
tree | c9d35f2c527c7f946a772f91d9de24a15f34f157 | |
parent | 5ec4d195cd2e0215da609abaaf26d5ca9c984153 (diff) | |
parent | d76fa45b4223eed8014d2115d0c261320feaa0f1 (diff) |
Merge pull request #26595 from vespa-engine/vekterli/take-queue-mutex-on-flush
Ensure proper memory visibility on distributor stripe flush
-rw-r--r-- | storage/src/vespa/storage/distributor/distributor_stripe.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/storage/src/vespa/storage/distributor/distributor_stripe.cpp b/storage/src/vespa/storage/distributor/distributor_stripe.cpp index 782dd9d7e12..616fd77fdd7 100644 --- a/storage/src/vespa/storage/distributor/distributor_stripe.cpp +++ b/storage/src/vespa/storage/distributor/distributor_stripe.cpp @@ -127,6 +127,12 @@ void DistributorStripe::send_shutdown_abort_reply(const std::shared_ptr<api::Sto } void DistributorStripe::flush_and_close() { + // This function is called from a different thread than that of the stripe + // itself, so we need to take the same mutex to form a memory visibility pair. + // It is important that no flushing ever sends any _requests_, as these + // will most likely synchronously be bounced by the already shut down RPC + // layer, causing a deadlock when the response call chain arrives back here. + std::lock_guard lock(_external_message_mutex); for (auto& msg : _messageQueue) { if (!msg->getType().isReply()) { send_shutdown_abort_reply(msg); |