summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/delete.h
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2016-03-25 11:41:00 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2016-03-25 11:46:51 -0400
commit178e241b81882f85a58deda960d80607a77e1c3a (patch)
treed17217e4355c6a9c3a404c0a352912e9616f8b64 /src/mongo/db/exec/delete.h
parent4a38dcf183c1024b41f9d68b0ca8e2f885f1e669 (diff)
downloadmongo-178e241b81882f85a58deda960d80607a77e1c3a.tar.gz
SERVER-22178 Always retry sorted findAndModify upon write conflict.
Previously, if there was a WriteConflictException while actually doing the update or delete, we would retry the findAndModify, but if the update or delete stage detected that the document was already deleted or that it no longer matched the predicate, it would not retry. This patch ensures the findAndModify will be retried in either of those scenarios.
Diffstat (limited to 'src/mongo/db/exec/delete.h')
-rw-r--r--src/mongo/db/exec/delete.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/db/exec/delete.h b/src/mongo/db/exec/delete.h
index 55879182adb..9a71c597e63 100644
--- a/src/mongo/db/exec/delete.h
+++ b/src/mongo/db/exec/delete.h
@@ -44,7 +44,7 @@ struct DeleteStageParams {
fromMigrate(false),
isExplain(false),
returnDeleted(false),
- canonicalQuery(NULL) {}
+ canonicalQuery(nullptr) {}
// Should we delete all documents returned from the child (a "multi delete"), or at most one
// (a "single delete")?
@@ -62,6 +62,9 @@ struct DeleteStageParams {
// The parsed query predicate for this delete. Not owned here.
CanonicalQuery* canonicalQuery;
+
+ // The user-requested sort specification. Currently used just for findAndModify.
+ BSONObj sort;
};
/**
@@ -105,6 +108,12 @@ public:
static long long getNumDeleted(const PlanExecutor& exec);
private:
+ /**
+ * Stores 'idToRetry' in '_idRetrying' so the delete can be retried during the next call to
+ * work(). Always returns NEED_YIELD and sets 'out' to WorkingSet::INVALID_ID.
+ */
+ StageState prepareToRetryWSM(WorkingSetID idToRetry, WorkingSetID* out);
+
DeleteStageParams _params;
// Not owned by us.