Rollback implements rollback method of two-phase commit worker.
(ctx context.Context, wb twopc.WriteBatch)
| 231 | |
| 232 | // Rollback implements rollback method of two-phase commit worker. |
| 233 | func (s *Storage) Rollback(ctx context.Context, wb twopc.WriteBatch) (err error) { |
| 234 | el, ok := wb.(*ExecLog) |
| 235 | |
| 236 | if !ok { |
| 237 | return errors.New("unexpected WriteBatch type") |
| 238 | } |
| 239 | |
| 240 | s.Lock() |
| 241 | defer s.Unlock() |
| 242 | |
| 243 | if !equalTxID(&s.id, &TxID{el.ConnectionID, el.SeqNo, el.Timestamp}) { |
| 244 | return fmt.Errorf("twopc: inconsistent state, currently in tx: "+ |
| 245 | "conn = %d, seq = %d, time = %d", s.id.ConnectionID, s.id.SeqNo, s.id.Timestamp) |
| 246 | } |
| 247 | |
| 248 | if s.tx != nil { |
| 249 | s.tx.Rollback() |
| 250 | s.tx = nil |
| 251 | s.queries = nil |
| 252 | } |
| 253 | |
| 254 | return nil |
| 255 | } |
| 256 | |
| 257 | // Query implements read-only query feature. |
| 258 | func (s *Storage) Query(ctx context.Context, queries []Query) (columns []string, types []string, |