summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorNathan Myers <ncm@cantrip.org>2017-08-09 18:53:06 -0400
committerNathan Myers <ncm@cantrip.org>2017-08-09 18:53:06 -0400
commit7653edd84b312a372500814587589633f11b5d2f (patch)
tree158008ba916599bf07746febe40dab54f275c7b7 /src/mongo/db
parent99c6768bf6931114657e108bd9f3ea96e3577c10 (diff)
downloadmongo-7653edd84b312a372500814587589633f11b5d2f.tar.gz
SERVER-29136 Op log deletions get shard keys
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/matcher/path.h9
-rw-r--r--src/mongo/db/op_observer_impl.cpp24
2 files changed, 16 insertions, 17 deletions
diff --git a/src/mongo/db/matcher/path.h b/src/mongo/db/matcher/path.h
index 40019ff832c..cb0c5fbe40c 100644
--- a/src/mongo/db/matcher/path.h
+++ b/src/mongo/db/matcher/path.h
@@ -40,6 +40,13 @@ namespace mongo {
class ElementPath {
public:
+ ElementPath(StringData path, bool traverseNonLeafArr = true, bool traverseLeafArr = true)
+ : _shouldTraverseNonleafArrays(traverseNonLeafArr),
+ _shouldTraverseLeafArray(traverseLeafArr),
+ _fieldRef(path) {}
+
+ // TODO: replace uses of members below with regular construction.
+ ElementPath() {}
Status init(StringData path);
void setTraverseNonleafArrays(bool b) {
@@ -60,9 +67,9 @@ public:
}
private:
- FieldRef _fieldRef;
bool _shouldTraverseNonleafArrays;
bool _shouldTraverseLeafArray;
+ FieldRef _fieldRef;
};
class ElementIterator {
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index 43341431068..c51f6407677 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -182,19 +182,11 @@ void OpObserverImpl::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArg
updateSessionProgress(opCtx, opTime);
}
-CollectionShardingState::DeleteState OpObserverImpl::aboutToDelete(OperationContext* opCtx,
- const NamespaceString& nss,
- const BSONObj& doc) {
- CollectionShardingState::DeleteState deleteState;
- BSONElement idElement = doc["_id"];
- if (!idElement.eoo()) {
- deleteState.idDoc = idElement.wrap();
- }
-
- auto css = CollectionShardingState::get(opCtx, nss.ns());
- deleteState.isMigrating = css->isDocumentInMigratingChunk(opCtx, doc);
-
- return deleteState;
+auto OpObserverImpl::aboutToDelete(OperationContext* opCtx,
+ NamespaceString const& nss,
+ BSONObj const& doc) -> CollectionShardingState::DeleteState {
+ auto* css = CollectionShardingState::get(opCtx, nss.ns());
+ return CollectionShardingState::DeleteState(opCtx, css, doc);
}
void OpObserverImpl::onDelete(OperationContext* opCtx,
@@ -203,13 +195,13 @@ void OpObserverImpl::onDelete(OperationContext* opCtx,
StmtId stmtId,
CollectionShardingState::DeleteState deleteState,
bool fromMigrate) {
- if (deleteState.idDoc.isEmpty())
+ if (deleteState.documentKey.isEmpty())
return;
auto opTime =
- repl::logOp(opCtx, "d", nss, uuid, deleteState.idDoc, nullptr, fromMigrate, stmtId);
+ repl::logOp(opCtx, "d", nss, uuid, deleteState.documentKey, nullptr, fromMigrate, stmtId);
AuthorizationManager::get(opCtx->getServiceContext())
- ->logOp(opCtx, "d", nss, deleteState.idDoc, nullptr);
+ ->logOp(opCtx, "d", nss, deleteState.documentKey, nullptr);
auto css = CollectionShardingState::get(opCtx, nss.ns());
if (!fromMigrate) {