summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahooinc.com>2023-08-21 14:10:47 +0000
committerTor Brede Vekterli <vekterli@yahooinc.com>2023-08-21 14:10:47 +0000
commit58ff45c5a871e91499e262c1c66c2fb4fb3a1b49 (patch)
tree83ceeef3a1d60b635fb822f04e840e9fac2958ba /storage
parentb045c3f2fa147e1c551bc46a8266afe3204fa788 (diff)
Simplify `CancelScope` handling by moving out of optional
Diffstat (limited to 'storage')
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp16
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h3
-rw-r--r--storage/src/vespa/storage/distributor/persistencemessagetracker.cpp23
-rw-r--r--storage/src/vespa/storage/distributor/persistencemessagetracker.h3
4 files changed, 14 insertions, 31 deletions
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
index 842657fdf9c..c830b4d8618 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.cpp
@@ -151,11 +151,7 @@ GarbageCollectionOperation::onReceive(DistributorStripeMessageSender& sender,
}
void GarbageCollectionOperation::on_cancel(DistributorStripeMessageSender&, const CancelScope& cancel_scope) {
- if (!_cancel_scope) {
- _cancel_scope = cancel_scope;
- } else {
- _cancel_scope->merge(cancel_scope);
- }
+ _cancel_scope.merge(cancel_scope);
}
void GarbageCollectionOperation::update_replica_response_info_from_reply(uint16_t from_node, const api::RemoveLocationReply& reply) {
@@ -265,12 +261,10 @@ void GarbageCollectionOperation::update_last_gc_timestamp_in_db() {
}
void GarbageCollectionOperation::merge_received_bucket_info_into_db() {
- if (_cancel_scope) {
- if (_cancel_scope->fully_cancelled()) {
- return;
- } else if (_cancel_scope->partially_cancelled()) {
- _replica_info = prune_cancelled_nodes(_replica_info, *_cancel_scope);
- }
+ if (_cancel_scope.fully_cancelled()) {
+ return;
+ } else if (_cancel_scope.partially_cancelled()) {
+ _replica_info = prune_cancelled_nodes(_replica_info, _cancel_scope);
}
if (!_replica_info.empty()) {
// TODO avoid two separate DB ops for this. Current API currently does not make this elegant.
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h
index 098ae50368b..97efbe694de 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h
@@ -9,7 +9,6 @@
#include <vespa/storage/distributor/operation_sequencer.h>
#include <vespa/storage/distributor/operations/cancel_scope.h>
#include <vespa/vespalib/stllike/hash_map.h>
-#include <optional>
#include <vector>
namespace storage::distributor {
@@ -57,7 +56,7 @@ private:
RemoveCandidates _remove_candidates;
std::vector<SequencingHandle> _gc_write_locks;
std::vector<BucketCopy> _replica_info;
- std::optional<CancelScope> _cancel_scope;
+ CancelScope _cancel_scope;
uint32_t _max_documents_removed;
bool _is_done;
diff --git a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
index 8a60f4c787a..8f93facf6cd 100644
--- a/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
+++ b/storage/src/vespa/storage/distributor/persistencemessagetracker.cpp
@@ -41,11 +41,7 @@ PersistenceMessageTrackerImpl::~PersistenceMessageTrackerImpl() = default;
void
PersistenceMessageTrackerImpl::cancel(const CancelScope& cancel_scope)
{
- if (!_cancel_scope) {
- _cancel_scope = cancel_scope;
- } else {
- _cancel_scope->merge(cancel_scope);
- }
+ _cancel_scope.merge(cancel_scope);
}
void
@@ -61,13 +57,11 @@ PersistenceMessageTrackerImpl::prune_cancelled_nodes_if_present(
void
PersistenceMessageTrackerImpl::updateDB()
{
- if (_cancel_scope) {
- if (_cancel_scope->fully_cancelled()) {
- return; // Fully cancelled ops cannot mutate the DB at all
- } else if (_cancel_scope->partially_cancelled()) {
- prune_cancelled_nodes_if_present(_bucketInfo, *_cancel_scope);
- prune_cancelled_nodes_if_present(_remapBucketInfo, *_cancel_scope);
- }
+ if (_cancel_scope.fully_cancelled()) {
+ return; // Fully cancelled ops cannot mutate the DB at all
+ } else if (_cancel_scope.partially_cancelled()) {
+ prune_cancelled_nodes_if_present(_bucketInfo, _cancel_scope);
+ prune_cancelled_nodes_if_present(_remapBucketInfo, _cancel_scope);
}
for (const auto & entry : _bucketInfo) {
@@ -266,10 +260,7 @@ PersistenceMessageTrackerImpl::updateFailureResult(const api::BucketInfoReply& r
bool
PersistenceMessageTrackerImpl::node_is_effectively_cancelled(uint16_t node) const noexcept
{
- if (!_cancel_scope) {
- return false;
- }
- return _cancel_scope->node_is_cancelled(node); // Implicitly covers the fully cancelled case
+ return _cancel_scope.node_is_cancelled(node); // Implicitly covers the fully cancelled case
}
void
diff --git a/storage/src/vespa/storage/distributor/persistencemessagetracker.h b/storage/src/vespa/storage/distributor/persistencemessagetracker.h
index 36f35ddb2b4..8c44d70062c 100644
--- a/storage/src/vespa/storage/distributor/persistencemessagetracker.h
+++ b/storage/src/vespa/storage/distributor/persistencemessagetracker.h
@@ -8,7 +8,6 @@
#include <vespa/storageframework/generic/clock/timer.h>
#include <vespa/storageapi/messageapi/bucketinfocommand.h>
#include <vespa/storageapi/messageapi/bucketinforeply.h>
-#include <optional>
namespace storage::distributor {
@@ -80,7 +79,7 @@ private:
std::vector<BucketNodePair> _revertNodes;
mbus::Trace _trace;
framework::MilliSecTimer _requestTimer;
- std::optional<CancelScope> _cancel_scope;
+ CancelScope _cancel_scope;
uint32_t _n_persistence_replies_total;
uint32_t _n_successful_persistence_replies;
uint8_t _priority;