Details
Description
Summary:
On commands from mongos, mongod should return its lastCommittedOpTime (i.e. the timestamp from the opTime of its last committed write).
Design:
Inside appendReplyMetadata and appendReplyMetadataOnError in src/mongo/db/service_entry_point_mongod.cpp, check if the node's ShardingState is enabled (which means its in a sharded cluster) or that it is a config server, and get the lastCommittedOpTime from the replication coordinator and append it to the metadata BSONObjBuilder.
if (ShardingState::get(opCtx)->enabled() || serverGlobalParams.clusterRole == ClusterRole::ConfigServer) {
|
auto lastCommittedOpTime =
|
repl::ReplicationCoordinator::get(opCtx)->getLastCommittedOpTime();
|
metadataBob->append(kLastCommittedOpTimeFieldName, lastCommittedOpTime.getTimestamp());
|
}
|
Open Questions:
- Should config servers return their lastCommittedOpTime?
- Decision: Yes they should