summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorauto-revert-processor <dev-prod-dag@mongodb.com>2022-10-22 03:34:21 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-22 04:06:30 +0000
commite5fa2aabe4ddfe1d18d94e326d1ef3dc4ca2af26 (patch)
tree76b6db279d573582be14a2812ac8b184a97a0f74 /src/mongo/db/commands
parent0fb4acf0e581936924c2353a6cfdb29ce5f06348 (diff)
downloadmongo-e5fa2aabe4ddfe1d18d94e326d1ef3dc4ca2af26.tar.gz
Revert "SERVER-62880 Use tid field to apply applyOps and transactions oplog entries"
This reverts commit 9a60ad4e90d5e2faccedcea26e31b1992676d395.
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/oplog_application_checks.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/mongo/db/commands/oplog_application_checks.cpp b/src/mongo/db/commands/oplog_application_checks.cpp
index 816a8157403..c4f65bb478b 100644
--- a/src/mongo/db/commands/oplog_application_checks.cpp
+++ b/src/mongo/db/commands/oplog_application_checks.cpp
@@ -62,19 +62,15 @@ Status OplogApplicationChecks::checkOperationAuthorization(OperationContext* opC
BSONElement nsElem = oplogEntry["ns"];
checkBSONType(BSONType::String, nsElem);
- boost::optional<TenantId> tid = oplogEntry.hasElement("tid")
- ? boost::make_optional<TenantId>(TenantId::parseFromBSON(oplogEntry["tid"]))
- : boost::none;
- NamespaceString nss =
- NamespaceStringUtil::deserialize(tid, oplogEntry["ns"].checkAndGetStringData());
+ NamespaceString ns(oplogEntry["ns"].checkAndGetStringData());
if (oplogEntry.hasField("ui"_sd)) {
// ns by UUID overrides the ns specified if they are different.
auto catalog = CollectionCatalog::get(opCtx);
boost::optional<NamespaceString> uuidCollNS =
catalog->lookupNSSByUUID(opCtx, getUUIDFromOplogEntry(oplogEntry));
- if (uuidCollNS && *uuidCollNS != nss)
- nss = *uuidCollNS;
+ if (uuidCollNS && *uuidCollNS != ns)
+ ns = *uuidCollNS;
}
BSONElement oElem = oplogEntry["o"];
@@ -88,19 +84,19 @@ Status OplogApplicationChecks::checkOperationAuthorization(OperationContext* opC
return Status(ErrorCodes::FailedToParse, "Unrecognized command in op");
}
- auto dbNameForAuthCheck = nss.dbName();
+ std::string dbNameForAuthCheck = ns.db().toString();
if (commandName == "renameCollection") {
// renameCollection commands must be run on the 'admin' database. Its arguments are
// fully qualified namespaces. Catalog internals don't know the op produced by running
// renameCollection was originally run on 'admin', so we must restore this.
- dbNameForAuthCheck = DatabaseName(nss.tenantId(), "admin");
+ dbNameForAuthCheck = "admin";
}
// TODO reuse the parse result for when we run() later. Note that when running,
// we must use a potentially different dbname.
return [&] {
try {
- auto request = OpMsgRequestBuilder::create(nss.dbName(), o);
+ auto request = OpMsgRequest::fromDBAndBody(dbNameForAuthCheck, o);
commandInOplogEntry->parse(opCtx, request)->checkAuthorization(opCtx, request);
return Status::OK();
} catch (const DBException& e) {
@@ -110,7 +106,7 @@ Status OplogApplicationChecks::checkOperationAuthorization(OperationContext* opC
}
if (opType == "i"_sd) {
- return auth::checkAuthForInsert(authSession, opCtx, nss);
+ return auth::checkAuthForInsert(authSession, opCtx, ns);
} else if (opType == "u"_sd) {
BSONElement o2Elem = oplogEntry["o2"];
checkBSONType(BSONType::Object, o2Elem);
@@ -126,14 +122,14 @@ Status OplogApplicationChecks::checkOperationAuthorization(OperationContext* opC
return auth::checkAuthForUpdate(authSession,
opCtx,
- nss,
+ ns,
o2,
write_ops::UpdateModification::parseFromOplogEntry(
o, write_ops::UpdateModification::DiffOptions{}),
upsert);
} else if (opType == "d"_sd) {
- return auth::checkAuthForDelete(authSession, opCtx, nss, o);
+ return auth::checkAuthForDelete(authSession, opCtx, ns, o);
} else if (opType == "db"_sd) {
// It seems that 'db' isn't used anymore. Require all actions to prevent casual use.
ActionSet allActions;