aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp')
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
index b3326a43be2..4283386a1bc 100644
--- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
@@ -158,6 +158,7 @@ void
TwoPhaseUpdateOperation::startFastPathUpdate(DistributorMessageSender& sender)
{
_mode = Mode::FAST_PATH;
+ LOG(debug, "Update(%s) fast path: sending Update commands", _updateCmd->getDocumentId().toString().c_str());
auto updateOperation = std::make_shared<UpdateOperation>(_manager, _bucketSpace, _updateCmd, _updateMetric);
UpdateOperation & op = *updateOperation;
IntermediateMessageSender intermediate(_sentMessageMap, std::move(updateOperation), sender);
@@ -364,6 +365,11 @@ TwoPhaseUpdateOperation::handleSafePathReceivedGet(DistributorMessageSender& sen
sendReplyWithResult(sender, reply.getResult());
return;
}
+ if (may_restart_with_fast_path(reply)) {
+ restart_with_fast_path_due_to_consistent_get_timestamps(sender);
+ return;
+ }
+
document::Document::SP docToUpdate;
api::Timestamp putTimestamp = _manager.getUniqueTimestamp();
@@ -399,6 +405,23 @@ TwoPhaseUpdateOperation::handleSafePathReceivedGet(DistributorMessageSender& sen
}
}
+bool TwoPhaseUpdateOperation::may_restart_with_fast_path(const api::GetReply& reply) {
+ return (_manager.getDistributor().getConfig().update_fast_path_restart_enabled() &&
+ reply.wasFound() &&
+ reply.had_consistent_replicas());
+}
+
+void TwoPhaseUpdateOperation::restart_with_fast_path_due_to_consistent_get_timestamps(DistributorMessageSender& sender) {
+ LOG(debug, "Update(%s): all Gets returned in initial safe path were consistent, restarting in fast path mode",
+ _updateCmd->getDocumentId().toString().c_str());
+ if (lostBucketOwnershipBetweenPhases()) {
+ sendLostOwnershipTransientErrorReply(sender);
+ return;
+ }
+ _updateMetric.fast_path_restarts.inc();
+ startFastPathUpdate(sender);
+}
+
bool
TwoPhaseUpdateOperation::processAndMatchTasCondition(DistributorMessageSender& sender,
const document::Document& candidateDoc)
@@ -487,7 +510,7 @@ TwoPhaseUpdateOperation::onClose(DistributorMessageSender& sender) {
std::shared_ptr<Operation> cb = _sentMessageMap.pop();
if (cb) {
- IntermediateMessageSender intermediate(_sentMessageMap, std::shared_ptr<Operation > (), sender);
+ IntermediateMessageSender intermediate(_sentMessageMap, std::shared_ptr<Operation>(), sender);
cb->onClose(intermediate);
// We will _only_ forward UpdateReply instances up, since those
// are created by UpdateOperation and are bound to the original