jstests/core/txns/libs/prepare_helpers.js
/**
     * Commits the active transaction on the session.
     *
     * @return {object} the response to the 'commitTransaction' command.
     */
Commits the active transaction on the session.
@return {object} the response to the 'commitTransaction' command.
Commits the active transaction on the session . @return { object } the response to the ' commitTransaction ' command .
function commitTransaction(session, commitTimestamp) {
        assert(session);
        let cmd = {commitTransaction: 1, commitTimestamp: commitTimestamp};
        const writeConcern = session.getTxnWriteConcern_forTesting();
        if (writeConcern !== undefined) {
            cmd.writeConcern = writeConcern;
        }
        const res = session.getDatabase('admin').adminCommand(cmd);
        if (res.ok) {
            assert.commandWorked(session.commitTransaction_forTesting());
        } else {
            assert.commandWorkedOrFailedWithCode(session.abortTransaction_forTesting(),
                                                 ErrorCodes.NoSuchTransaction);
        }
        return res;
    }
function commitTransaction ( session , commitTimestamp ) { assert ( session ) ; let cmd = { commitTransaction : 1 , commitTimestamp : commitTimestamp } ; const writeConcern = session . getTxnWriteConcern_forTesting ( ) ; if ( writeConcern !== undefined ) { cmd . writeConcern = writeConcern ; } const res = session . getDatabase ( 'admin' ) . adminCommand ( cmd ) ; if ( res . ok ) { assert . commandWorked ( session . commitTransaction_forTesting ( ) ) ; } else { assert . commandWorkedOrFailedWithCode ( session . abortTransaction_forTesting ( ) , ErrorCodes . NoSuchTransaction ) ; } return res ; }
Commits the active transaction on the session.
Commits the active transaction on the session .
// End the transaction on the shell session.