// Begin transaction func (s *dbStore) Begin() (kv.Transaction, error) { s.mu.Lock() defer s.mu.Unlock() beginVer, err := globalVersionProvider.CurrentVersion() if err != nil { return nil, err } txn := &dbTxn{ tid: beginVer.Ver, valid: true, store: s, version: kv.MinVersion, snapshotVals: make(map[string][]byte), } log.Debugf("Begin txn:%d", txn.tid) txn.UnionStore, err = kv.NewUnionStore(&dbSnapshot{ db: s.db, version: beginVer, }) if err != nil { return nil, errors.Trace(err) } return txn, nil }
// Begin transaction func (s *dbStore) Begin() (kv.Transaction, error) { providerMu.RLock() beginVer, err := globalVersionProvider.CurrentVersion() providerMu.RUnlock() if err != nil { return nil, errors.Trace(err) } s.mu.RLock() closed := s.closed s.mu.RUnlock() if closed { return nil, errors.Trace(ErrDBClosed) } txn := &dbTxn{ tid: beginVer.Ver, valid: true, store: s, version: kv.MinVersion, snapshotVals: make(map[string]struct{}), opts: make(map[kv.Option]interface{}), } log.Debugf("Begin txn:%d", txn.tid) txn.UnionStore = kv.NewUnionStore(newSnapshot(s, s.db, beginVer), options(txn.opts)) return txn, nil }
func newHbaseTxn(t themis.Txn, storeName string) *hbaseTxn { return &hbaseTxn{ txn: t, valid: true, storeName: storeName, tid: t.GetStartTS(), us: kv.NewUnionStore(newHbaseSnapshot(t, storeName)), } }
func (s *hbaseStore) Begin() (kv.Transaction, error) { s.mu.Lock() defer s.mu.Unlock() hbaseCli := s.getHBaseClient() t := themis.NewTxn(hbaseCli) txn := newHbaseTxn(t, s.storeName) txn.UnionStore = kv.NewUnionStore(newHbaseSnapshot(t, s.storeName)) return txn, nil }
func newHbaseTxn(t *themis.Txn, storeName string) *hbaseTxn { opts := make(map[kv.Option]interface{}) return &hbaseTxn{ Txn: t, valid: true, storeName: storeName, tid: t.GetStartTS(), UnionStore: kv.NewUnionStore(newHbaseSnapshot(t, storeName), options(opts)), opts: opts, } }
func newTxn(s *dbStore, ver kv.Version) *dbTxn { txn := &dbTxn{ us: kv.NewUnionStore(newSnapshot(s, ver)), store: s, tid: ver.Ver, valid: true, version: kv.MinVersion, lockedKeys: make(map[string]struct{}), } log.Debugf("[kv] Begin txn:%d", txn.tid) return txn }
func newTiKVTxn(store *tikvStore) (*tikvTxn, error) { startTS, err := store.getTimestampWithRetry() if err != nil { return nil, errors.Trace(err) } ver := kv.NewVersion(startTS) return &tikvTxn{ us: kv.NewUnionStore(newTiKVSnapshot(store, ver)), store: store, startTS: startTS, valid: true, }, nil }
func newTiKVTxn(store *tikvStore) (*tikvTxn, error) { bo := NewBackoffer(tsoMaxBackoff, context.Background()) startTS, err := store.getTimestampWithRetry(bo) if err != nil { return nil, errors.Trace(err) } ver := kv.NewVersion(startTS) return &tikvTxn{ us: kv.NewUnionStore(newTiKVSnapshot(store, ver)), store: store, startTS: startTS, valid: true, }, nil }
// Begin transaction func (s *dbStore) Begin() (kv.Transaction, error) { s.mu.Lock() defer s.mu.Unlock() snapshot, err := s.db.GetSnapshot() if err != nil { return nil, err } txn := &dbTxn{ startTs: time.Now(), tID: atomic.AddInt64(&globalID, 1), valid: true, store: s, snapshotVals: make(map[string][]byte), } log.Debugf("Begin txn:%d", txn.tID) txn.UnionStore, err = kv.NewUnionStore(&dbSnapshot{snapshot}) if err != nil { return nil, err } return txn, nil }