From 1ec4f50e3c9999d404b7f90ea402a82cdc0ea69c Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Wed, 18 Nov 2020 11:04:30 +0100 Subject: [PATCH] db,view: remove duplicate entries from the list of target endpoints If a list of target endpoints for sending view updates contains duplicates, it results in benign (but annoying) broken promise errors happening due to duplicated write response handlers being instantiated for a single endpoint. In order to avoid such errors, target remote endpoints are deduplicated from the list of pending endpoints. A similar issue (#5459) solved the case for duplicated local endpoints, but that didn't solve the general case. Fixes #7572 Closes #7641 (cherry picked from commit c0d72b44910924f0d60b096cb87e7ead2ec44969) --- db/view/view.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/db/view/view.cc b/db/view/view.cc index 323b2fded1..5ccc8f23ad 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -1241,6 +1241,14 @@ future<> mutate_MV( } } } + // It's still possible that a target endpoint is dupliated in the remote endpoints list, + // so let's get rid of the duplicate if it exists + if (target_endpoint) { + auto remote_it = std::find(remote_endpoints.begin(), remote_endpoints.end(), *target_endpoint); + if (remote_it != remote_endpoints.end()) { + remote_endpoints.erase(remote_it); + } + } if (target_endpoint && *target_endpoint == my_address) { ++stats.view_updates_pushed_local;