code: func (st *TxnState) Commit(ctx context.Context) error {
  	defer st.reset()
  	if len(st.mutations) != 0 || len(st.dirtyTableOP) != 0 || st.buf.Len() != 0 {
  		logutil.Logger(context.Background()).Error("the code should never run here",
  			zap.String("TxnState", st.GoString()),
  			zap.Stack("something must be wrong"))
  		return errors.New("invalid transaction")
  	}
  	if st.doNotCommit != nil {
  		if err1 := st.Transaction.Rollback(); err1 != nil {
  			logutil.Logger(context.Background()).Error("rollback error", zap.Error(err1))
  		}
  		return errors.Trace(st.doNotCommit)
  	}
  
  	// mockCommitError8942 is used for PR #8942.
  	failpoint.Inject("mockCommitError8942", func(val failpoint.Value) {
  		if val.(bool) {
  			failpoint.Return(kv.ErrRetryable)
  		}
  	})
  
  	// mockCommitRetryForAutoID is used to mock an commit retry for adjustAutoIncrementDatum.
  	failpoint.Inject("mockCommitRetryForAutoID", func(val failpoint.Value) {
  		if val.(bool) && !mockAutoIDRetry() {
  			enableMockAutoIDRetry()
  			failpoint.Return(kv.ErrRetryable)
  		}
  	})
  
  	return st.Transaction.Commit(ctx)
  }
docs: // Commit overrides the Transaction interface.