summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/mongo_process_interface.h
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2018-09-18 13:23:54 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2018-11-01 16:59:04 -0400
commit9282c05723eb9f15a6591613007ebe68561c88cb (patch)
treedf797690af51e981ca3845bd124c88fb93d88b69 /src/mongo/db/pipeline/mongo_process_interface.h
parentb43765f2caa4c152204f7361c28e091247443c18 (diff)
downloadmongo-9282c05723eb9f15a6591613007ebe68561c88cb.tar.gz
SERVER-36813 Be careful when choosing default uniqueKey
Before doing so, refresh the catalog cache to make sure the mongos serving the request is at least somewhat up to date. Additionally, communicate the epoch used to choose the uniqueKey from mongos to the shards, and raise an error from the shards and terminate the aggregation if the epoch of the targeted collection ever changes.
Diffstat (limited to 'src/mongo/db/pipeline/mongo_process_interface.h')
-rw-r--r--src/mongo/db/pipeline/mongo_process_interface.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mongo/db/pipeline/mongo_process_interface.h b/src/mongo/db/pipeline/mongo_process_interface.h
index da96b66c4b0..033d9658c51 100644
--- a/src/mongo/db/pipeline/mongo_process_interface.h
+++ b/src/mongo/db/pipeline/mongo_process_interface.h
@@ -108,16 +108,20 @@ public:
virtual bool isSharded(OperationContext* opCtx, const NamespaceString& ns) = 0;
/**
- * Inserts 'objs' into 'ns' and throws a UserException if the insert fails.
+ * Inserts 'objs' into 'ns' and throws a UserException if the insert fails. If 'targetEpoch' is
+ * set, throws ErrorCodes::StaleEpoch if the targeted collection does not have the same epoch or
+ * the epoch changes during the course of the insert.
*/
virtual void insert(const boost::intrusive_ptr<ExpressionContext>& expCtx,
const NamespaceString& ns,
std::vector<BSONObj>&& objs,
- const WriteConcernOptions& wc) = 0;
+ const WriteConcernOptions& wc,
+ boost::optional<OID> targetEpoch) = 0;
/**
* Updates the documents matching 'queries' with the objects 'updates'. Throws a UserException
- * if any of the updates fail.
+ * if any of the updates fail. If 'targetEpoch' is set, throws ErrorCodes::StaleEpoch if the
+ * targeted collection does not have the same epoch, or if the epoch changes during the update.
*/
virtual void update(const boost::intrusive_ptr<ExpressionContext>& expCtx,
const NamespaceString& ns,
@@ -125,7 +129,8 @@ public:
std::vector<BSONObj>&& updates,
const WriteConcernOptions& wc,
bool upsert,
- bool multi) = 0;
+ bool multi,
+ boost::optional<OID> targetEpoch) = 0;
virtual CollectionIndexUsageMap getIndexStats(OperationContext* opCtx,
const NamespaceString& ns) = 0;
@@ -269,6 +274,16 @@ public:
virtual bool uniqueKeyIsSupportedByIndex(const boost::intrusive_ptr<ExpressionContext>& expCtx,
const NamespaceString& nss,
const std::set<FieldPath>& uniqueKeyPaths) const = 0;
+
+ /**
+ * Refreshes the CatalogCache entry for the namespace 'nss', and returns the epoch associated
+ * with that namespace, if any. Note that this refresh will not necessarily force a new
+ * request to be sent to the config servers. If another thread has already requested a refresh,
+ * it will instead wait for that response.
+ */
+ virtual boost::optional<OID> refreshAndGetEpoch(
+ const boost::intrusive_ptr<ExpressionContext>& expCtx,
+ const NamespaceString& nss) const = 0;
};
} // namespace mongo