MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / Rollback

Method Rollback

storage/storage.go:233–255  ·  view source on GitHub ↗

Rollback implements rollback method of two-phase commit worker.

(ctx context.Context, wb twopc.WriteBatch)

Source from the content-addressed store, hash-verified

231
232// Rollback implements rollback method of two-phase commit worker.
233func (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.
258func (s *Storage) Query(ctx context.Context, queries []Query) (columns []string, types []string,

Callers

nothing calls this directly

Calls 4

equalTxIDFunction · 0.85
ErrorfMethod · 0.80
NewMethod · 0.65
RollbackMethod · 0.65

Tested by

no test coverage detected