SERVER-126301 Add 'c' oplog entry for setAllowChunkOperations (#53508)

GitOrigin-RevId: adbe9993defa2b23ee335e13002d558ef453edd3
This commit is contained in:
Aitor Esteve Alvarado 2026-05-19 08:44:44 +02:00 committed by MongoDB Bot
parent 69a44bc5d6
commit 5b8d5a4c78
10 changed files with 40 additions and 0 deletions

View File

@ -761,6 +761,11 @@ public:
virtual void onInvalidateCollectionMetadata(OperationContext* opCtx,
const repl::OplogEntry& op) = 0;
/**
* Called when the authoritative CSS needs to update the value of allowChunkOperations.
*/
virtual void onSetAllowChunkOperations(OperationContext* opCtx, const repl::OplogEntry& op) = 0;
/**
* Called when 'truncateRange' is called on a collection.
* Out parameter 'opTime' is updated to the optime of the oplog entry logged.

View File

@ -296,6 +296,8 @@ public:
void onInvalidateCollectionMetadata(OperationContext* opCtx, const repl::OplogEntry& op) final {
}
void onSetAllowChunkOperations(OperationContext* opCtx, const repl::OplogEntry& op) final {}
void onTruncateRange(OperationContext* opCtx,
const CollectionPtr& coll,
const RecordId& minRecordId,

View File

@ -286,6 +286,8 @@ public:
void onInvalidateCollectionMetadata(OperationContext* opCtx,
const repl::OplogEntry& op) override {}
void onSetAllowChunkOperations(OperationContext* opCtx, const repl::OplogEntry& op) override {}
void onTruncateRange(OperationContext* opCtx,
const CollectionPtr& coll,
const RecordId& minRecordId,

View File

@ -699,6 +699,11 @@ public:
o->onInvalidateCollectionMetadata(opCtx, op);
}
void onSetAllowChunkOperations(OperationContext* opCtx, const repl::OplogEntry& op) override {
for (auto& o : _observers)
o->onSetAllowChunkOperations(opCtx, op);
}
void onTruncateRange(OperationContext* opCtx,
const CollectionPtr& coll,
const RecordId& minRecordId,

View File

@ -1328,6 +1328,12 @@ const StringMap<ApplyOpMetadata> kOpsMap = {
opCtx->getServiceContext()->getOpObserver()->onInvalidateCollectionMetadata(opCtx, *op);
return Status::OK();
}}},
{"setAllowChunkOperations",
{[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode)
-> Status {
opCtx->getServiceContext()->getOpObserver()->onSetAllowChunkOperations(opCtx, *op);
return Status::OK();
}}},
{"truncateRange",
{[](OperationContext* opCtx, const ApplierOperation& op, OplogApplication::Mode mode)
-> Status {

View File

@ -105,6 +105,7 @@ enums:
kCreateDatabaseMetadata: "createDatabaseMetadata"
kDropDatabaseMetadata: "dropDatabaseMetadata"
kInvalidateCollectionMetadata: "invalidateCollectionMetadata"
kSetAllowChunkOperations: "setAllowChunkOperations"
kTruncateRange: "truncateRange"
kUpgradeDowngradeViewlessTimeseries: "upgradeDowngradeViewlessTimeseries"
kSetMultikeyMetadata: "setMultikeyMetadata"

View File

@ -545,6 +545,7 @@ RollbackImpl::_namespacesAndUUIDsForOp(const OplogEntry& oplogEntry) {
case OplogEntry::CommandType::kCollMod:
case OplogEntry::CommandType::kTruncateRange:
case OplogEntry::CommandType::kInvalidateCollectionMetadata:
case OplogEntry::CommandType::kSetAllowChunkOperations:
case OplogEntry::CommandType::kSetMultikeyMetadata: {
// For all other command types, we should be able to parse the collection name from
// the first command argument.

View File

@ -78,3 +78,14 @@ structs:
CollectionShardingStateDeltaOplogEntry:
description: "Oplog entry format for delta changes to apply to the overall CSS"
strict: false
SetAllowChunkOperationsOplogEntry:
description: "Oplog entry format to signal the change of allowChunkOperations"
strict: false
fields:
setAllowChunkOperations:
type: string
description: "Collection name for which we are changing allowChunkOperations"
allowChunkOperations:
type: bool
description: "The new value of allowChunkOperations"

View File

@ -752,4 +752,9 @@ void ShardServerOpObserver::onInvalidateCollectionMetadata(OperationContext* opC
}
}
void ShardServerOpObserver::onSetAllowChunkOperations(OperationContext* opCtx,
const repl::OplogEntry& op) {
// TODO (SERVER-121209): implement.
}
} // namespace mongo

View File

@ -147,6 +147,8 @@ public:
void onInvalidateCollectionMetadata(OperationContext* opCtx,
const repl::OplogEntry& op) override;
void onSetAllowChunkOperations(OperationContext* opCtx, const repl::OplogEntry& op) override;
};
} // namespace mongo