summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahooinc.com>2023-09-08 12:21:30 +0000
committerTor Brede Vekterli <vekterli@yahooinc.com>2023-09-08 12:21:30 +0000
commit2aa0216ae69d33847a2e6db79722d19b49ff5744 (patch)
treebdd4f89c55f4795371a33904ff2348dfc1e36c59
parent6f3baf1022f84a11d136e4f04d1a8b35eb5d79e4 (diff)
Disambiguate outcome of replica pruning by using an explicit enum
-rw-r--r--storage/src/vespa/storage/distributor/persistencemessagetracker.cpp9
-rw-r--r--storage/src/vespa/storage/distributor/persistencemessagetracker.h16
2 files changed, 18 insertions, 7 deletions
diff --git a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
index 638f44eb5a7..43e3f6831d4 100644
--- a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
+++ b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
@@ -39,7 +39,7 @@ PersistenceMessageTracker::PersistenceMessageTracker(
PersistenceMessageTracker::~PersistenceMessageTracker() = default;
-bool
+PersistenceMessageTracker::PostPruningStatus
PersistenceMessageTracker::prune_cancelled_nodes_if_present(
BucketInfoMap& bucket_and_replicas,
const CancelScope& cancel_scope)
@@ -49,7 +49,8 @@ PersistenceMessageTracker::prune_cancelled_nodes_if_present(
info.second = prune_cancelled_nodes(info.second, cancel_scope);
any_replicas |= !info.second.empty();
}
- return any_replicas;
+ return (any_replicas ? PostPruningStatus ::ReplicasStillPresent
+ : PostPruningStatus::NoReplicasPresent);
}
void
@@ -59,8 +60,8 @@ PersistenceMessageTracker::updateDB()
if (_cancel_scope.fully_cancelled()) {
return; // Fully cancelled ops cannot mutate the DB at all
}
- const bool any_infos = prune_cancelled_nodes_if_present(_bucketInfo, _cancel_scope);
- const bool any_remapped = prune_cancelled_nodes_if_present(_remapBucketInfo, _cancel_scope);
+ const bool any_infos = still_has_replicas(prune_cancelled_nodes_if_present(_bucketInfo, _cancel_scope));
+ const bool any_remapped = still_has_replicas(prune_cancelled_nodes_if_present(_remapBucketInfo, _cancel_scope));
if (!(any_infos || any_remapped)) {
LOG(spam, "No usable bucket info left after pruning; returning without updating DB");
return;
diff --git a/storage/src/vespa/storage/distributor/persistencemessagetracker.h b/storage/src/vespa/storage/distributor/persistencemessagetracker.h
index a20bcb2c905..06ad8dc95b3 100644
--- a/storage/src/vespa/storage/distributor/persistencemessagetracker.h
+++ b/storage/src/vespa/storage/distributor/persistencemessagetracker.h
@@ -69,9 +69,19 @@ private:
uint8_t _priority;
bool _success;
- // Returns true iff `bucket_and_replicas` have at least 1 usable entry after pruning
- [[nodiscard]]static bool prune_cancelled_nodes_if_present(BucketInfoMap& bucket_and_replicas,
- const CancelScope& cancel_scope);
+ enum class PostPruningStatus {
+ ReplicasStillPresent,
+ NoReplicasPresent
+ };
+
+ constexpr static bool still_has_replicas(PostPruningStatus status) {
+ return status == PostPruningStatus::ReplicasStillPresent;
+ }
+
+ // Returns ReplicasStillPresent iff `bucket_and_replicas` has at least 1 usable entry after pruning,
+ // otherwise returns NoReplicasPresent
+ [[nodiscard]] static PostPruningStatus prune_cancelled_nodes_if_present(BucketInfoMap& bucket_and_replicas,
+ const CancelScope& cancel_scope);
[[nodiscard]] bool canSendReplyEarly() const;
void addBucketInfoFromReply(uint16_t node, const api::BucketInfoReply& reply);
void logSuccessfulReply(uint16_t node, const api::BucketInfoReply& reply) const;