CommitReadWriteTransaction commits read-write transaction and returns commit timestamp if successful.
(ctx context.Context)
| 150 | |
| 151 | // CommitReadWriteTransaction commits read-write transaction and returns commit timestamp if successful. |
| 152 | func (s *Session) CommitReadWriteTransaction(ctx context.Context) (spanner.CommitResponse, error) { |
| 153 | if !s.InReadWriteTransaction() { |
| 154 | return spanner.CommitResponse{}, errors.New("read-write transaction is not running") |
| 155 | } |
| 156 | |
| 157 | s.tcMutex.Lock() |
| 158 | defer s.tcMutex.Unlock() |
| 159 | |
| 160 | resp, err := s.tc.rwTxn.CommitWithReturnResp(ctx) |
| 161 | s.tc = nil |
| 162 | return resp, err |
| 163 | } |
| 164 | |
| 165 | // RollbackReadWriteTransaction rollbacks read-write transaction. |
| 166 | func (s *Session) RollbackReadWriteTransaction(ctx context.Context) error { |