summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathisbessamdb <mathis.bessa@mongodb.com>2022-10-31 19:58:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-31 21:31:27 +0000
commit8eccc479d9f5427fa369e1c1b473303411bdb78f (patch)
tree4b45121c346f9e24af9f6b9c2d7cf53051f808b5
parentb24674ac240b1cd713662a24996fae11f3afb8ad (diff)
downloadmongo-8eccc479d9f5427fa369e1c1b473303411bdb78f.tar.gz
SERVER-70411 Serialize and deserialize DbCheckOplogBatch correctly
-rw-r--r--jstests/serverless/native_tenant_data_isolation_basic_dollar_tenant.js3
-rw-r--r--jstests/serverless/native_tenant_data_isolation_basic_security_token.js7
-rw-r--r--src/mongo/db/commands/dbcheck.cpp18
-rw-r--r--src/mongo/db/repl/dbcheck.cpp7
4 files changed, 25 insertions, 10 deletions
diff --git a/jstests/serverless/native_tenant_data_isolation_basic_dollar_tenant.js b/jstests/serverless/native_tenant_data_isolation_basic_dollar_tenant.js
index 30d5cc6f572..1b648c75102 100644
--- a/jstests/serverless/native_tenant_data_isolation_basic_dollar_tenant.js
+++ b/jstests/serverless/native_tenant_data_isolation_basic_dollar_tenant.js
@@ -440,6 +440,9 @@ function runTest(featureFlagRequireTenantId) {
assert(validateRes.valid);
}
+ // Test dbCheck command.
+ { assert.commandWorked(testDb.runCommand({dbCheck: kCollName, '$tenant': kTenant})); }
+
rst.stopSet();
}
diff --git a/jstests/serverless/native_tenant_data_isolation_basic_security_token.js b/jstests/serverless/native_tenant_data_isolation_basic_security_token.js
index 74069b436f2..75ce3bf7e07 100644
--- a/jstests/serverless/native_tenant_data_isolation_basic_security_token.js
+++ b/jstests/serverless/native_tenant_data_isolation_basic_security_token.js
@@ -440,6 +440,13 @@ function runTest(featureFlagRequireTenantId) {
assert.commandWorked(tokenDB.runCommand({dropIndexes: kCollName, index: ["indexC"]}));
}
+ // Test dbCheck command.
+ // This should fail since dbCheck is not supporting using a security token.
+ {
+ assert.commandFailedWithCode(tokenDB.runCommand({dbCheck: kCollName}),
+ ErrorCodes.Unauthorized);
+ }
+
rst.stopSet();
}
runTest(true);
diff --git a/src/mongo/db/commands/dbcheck.cpp b/src/mongo/db/commands/dbcheck.cpp
index 1b1110abb29..166ee91e097 100644
--- a/src/mongo/db/commands/dbcheck.cpp
+++ b/src/mongo/db/commands/dbcheck.cpp
@@ -65,9 +65,8 @@ repl::OpTime _logOp(OperationContext* opCtx,
repl::MutableOplogEntry oplogEntry;
oplogEntry.setOpType(repl::OpTypeEnum::kCommand);
oplogEntry.setNss(nss);
- if (uuid) {
- oplogEntry.setUuid(*uuid);
- }
+ oplogEntry.setTid(nss.tenantId());
+ oplogEntry.setUuid(uuid);
oplogEntry.setObject(obj);
AutoGetOplog oplogWrite(opCtx, OplogAccessMode::kWrite);
return writeConflictRetry(
@@ -241,7 +240,8 @@ std::unique_ptr<DbCheckRun> getRun(OperationContext* opCtx,
// Get rid of generic command fields.
for (const auto& elem : obj) {
- if (!isGenericArgument(elem.fieldNameStringData())) {
+ const auto& fieldName = elem.fieldNameStringData();
+ if (!isGenericArgument(fieldName)) {
builder.append(elem);
}
}
@@ -251,11 +251,17 @@ std::unique_ptr<DbCheckRun> getRun(OperationContext* opCtx,
// If the dbCheck argument is a string, this is the per-collection form.
if (toParse["dbCheck"].type() == BSONType::String) {
return singleCollectionRun(
- opCtx, dbName, DbCheckSingleInvocation::parse(IDLParserContext(""), toParse));
+ opCtx,
+ dbName,
+ DbCheckSingleInvocation::parse(
+ IDLParserContext("", false /*apiStrict*/, dbName.tenantId()), toParse));
} else {
// Otherwise, it's the database-wide form.
return fullDatabaseRun(
- opCtx, dbName, DbCheckAllInvocation::parse(IDLParserContext(""), toParse));
+ opCtx,
+ dbName,
+ DbCheckAllInvocation::parse(
+ IDLParserContext("", false /*apiStrict*/, dbName.tenantId()), toParse));
}
}
diff --git a/src/mongo/db/repl/dbcheck.cpp b/src/mongo/db/repl/dbcheck.cpp
index aa295ce9ca7..3062ec42733 100644
--- a/src/mongo/db/repl/dbcheck.cpp
+++ b/src/mongo/db/repl/dbcheck.cpp
@@ -434,12 +434,11 @@ Status dbCheckOplogCommand(OperationContext* opCtx,
if (!opCtx->writesAreReplicated()) {
opTime = entry.getOpTime();
}
- auto type = OplogEntries_parse(IDLParserContext("type"), cmd.getStringField("type"));
- IDLParserContext ctx("o");
-
+ const auto type = OplogEntries_parse(IDLParserContext("type"), cmd.getStringField("type"));
+ const IDLParserContext ctx("o", false /*apiStrict*/, entry.getTid());
switch (type) {
case OplogEntriesEnum::Batch: {
- auto invocation = DbCheckOplogBatch::parse(ctx, cmd);
+ const auto invocation = DbCheckOplogBatch::parse(ctx, cmd);
return dbCheckBatchOnSecondary(opCtx, opTime, invocation);
}
case OplogEntriesEnum::Collection: {