From e5fa2aabe4ddfe1d18d94e326d1ef3dc4ca2af26 Mon Sep 17 00:00:00 2001 From: auto-revert-processor Date: Sat, 22 Oct 2022 03:34:21 +0000 Subject: Revert "SERVER-62880 Use tid field to apply applyOps and transactions oplog entries" This reverts commit 9a60ad4e90d5e2faccedcea26e31b1992676d395. --- src/mongo/db/commands/oplog_application_checks.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/mongo/db/commands') 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 tid = oplogEntry.hasElement("tid") - ? boost::make_optional(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 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; -- cgit v1.2.1