@@ -204,22 +204,33 @@ Status updateShardingCatalogEntryForCollectionInTxn(OperationContext* opCtx,
204
204
}
205
205
206
206
Status commitTxnForConfigDocument (OperationContext* opCtx, TxnNumber txnNumber) {
207
+ // Swap out the clients in order to get a fresh opCtx. Previous operations in this transaction
208
+ // that have been run on this opCtx would have set the timeout in the locker on the opCtx, but
209
+ // commit should not have a lock timeout.
210
+ auto newClient = getGlobalServiceContext ()->makeClient (" commitRefineShardKey" );
211
+ AlternativeClientRegion acr (newClient);
212
+ auto commitOpCtx = cc ().makeOperationContext ();
213
+ AuthorizationSession::get (commitOpCtx.get ()->getClient ())
214
+ ->grantInternalAuthorization (commitOpCtx.get ()->getClient ());
215
+ commitOpCtx.get ()->setLogicalSessionId (opCtx->getLogicalSessionId ().get ());
216
+ commitOpCtx.get ()->setTxnNumber (txnNumber);
217
+
207
218
BSONObjBuilder bob;
208
219
bob.append (" commitTransaction" , true );
209
220
bob.append (" autocommit" , false );
210
221
bob.append (OperationSessionInfo::kTxnNumberFieldName , txnNumber);
211
222
bob.append (WriteConcernOptions::kWriteConcernField , WriteConcernOptions::Majority);
212
223
213
224
BSONObjBuilder lsidBuilder (bob.subobjStart (" lsid" ));
214
- opCtx ->getLogicalSessionId ()->serialize (&bob);
225
+ commitOpCtx ->getLogicalSessionId ()->serialize (&bob);
215
226
lsidBuilder.doneFast ();
216
227
217
228
const auto cmdObj = bob.obj ();
218
229
219
230
const auto replyOpMsg =
220
- OpMsg::parseOwned (opCtx ->getServiceContext ()
231
+ OpMsg::parseOwned (commitOpCtx ->getServiceContext ()
221
232
->getServiceEntryPoint ()
222
- ->handleRequest (opCtx ,
233
+ ->handleRequest (commitOpCtx. get () ,
223
234
OpMsgRequest::fromDBAndBody (
224
235
NamespaceString::kAdminDb .toString (), cmdObj)
225
236
.serialize ())
0 commit comments