// Cleanup implements the MVCCStore interface.
// Cleanup API is deprecated, use CheckTxnStatus instead.
Cleanup implements the MVCCStore interface.
Cleanup API is deprecated, use CheckTxnStatus instead.
// Cleanup implements the MVCCStore interface . // Cleanup API is deprecated use CheckTxnStatus instead .
func (mvcc *MVCCRocksDB) Cleanup(key []byte, startTS, currentTS uint64) error {
	mvcc.mu.Lock()
	defer func() {
		mvcc.mu.Unlock()
		mvcc.deadlockDetector.CleanUp(startTS)
	}()
	batch := gorocksdb.NewWriteBatch()
	startKey := mvccEncode(key, lockVer)
	iter := newIterator(mvcc.db, &gorocksdb.Range{
		Start: startKey,
	})
	defer iter.Close()
	if iter.Valid() {
		dec := lockDecoder{
			expectKey: key,
		}
		ok, err := dec.Decode(iter)
		if err != nil {
			return err
		}
		if ok && dec.lock.startTS == startTS {
			if currentTS == 0 || uint64(oracle.ExtractPhysical(dec.lock.startTS))+dec.lock.ttl < uint64(oracle.ExtractPhysical(currentTS)) {
				if err = rollbackLock(batch, key, startTS); err != nil {
					return err
				}
				return mvcc.db.Write(gorocksdb.NewDefaultWriteOptions(), batch)
			}
			return dec.lock.lockErr(key)
		}
		c, ok, err := getTxnCommitInfo(iter, key, startTS)
		if err != nil {
			return errors.Trace(err)
		}
		if ok {
			if c.valueType != typeRollback {
				return ErrAlreadyCommitted(c.commitTS)
			}
			return nil
		}
	}
	value := mvccValue{
		valueType: typeRollback,
		startTS:   startTS,
		commitTS:  startTS,
	}
	writeKey := mvccEncode(key, startTS)
	writeValue, err := value.MarshalBinary()
	if err != nil {
		return errors.Trace(err)
	}
	batch.Put(writeKey, writeValue)
	return nil
}
func ( mvcc * MVCCRocksDB ) Cleanup ( key [ ] byte , startTS , currentTS uint64 ) error { mvcc . mu . Lock ( ) defer func ( ) { mvcc . mu . Unlock ( ) mvcc . deadlockDetector . CleanUp ( startTS ) } ( ) batch := gorocksdb . NewWriteBatch ( ) startKey := mvccEncode ( key , lockVer ) iter := newIterator ( mvcc . db , & gorocksdb . Range { Start : startKey , } ) defer iter . Close ( ) if iter . Valid ( ) { dec := lockDecoder { expectKey : key , } ok , err := dec . Decode ( iter ) if err != nil { return err } if ok && dec . lock . startTS == startTS { if currentTS == 0 || uint64 ( oracle . ExtractPhysical ( dec . lock . startTS ) ) + dec . lock . ttl < uint64 ( oracle . ExtractPhysical ( currentTS ) ) { if err = rollbackLock ( batch , key , startTS ) ; err != nil { return err } return mvcc . db . Write ( gorocksdb . NewDefaultWriteOptions ( ) , batch ) } return dec . lock . lockErr ( key ) } c , ok , err := getTxnCommitInfo ( iter , key , startTS ) if err != nil { return errors . Trace ( err ) } if ok { if c . valueType != typeRollback { return ErrAlreadyCommitted ( c . commitTS ) } return nil } } value := mvccValue { valueType : typeRollback , startTS : startTS , commitTS : startTS , } writeKey := mvccEncode ( key , startTS ) writeValue , err := value . MarshalBinary ( ) if err != nil { return errors . Trace ( err ) } batch . Put ( writeKey , writeValue ) return nil }
Cleanup implements the MVCCStore interface.
Cleanup implements the MVCCStore interface .
// If current transaction's lock exists. // If the lock has already outdated, clean up it. // Otherwise, return a locked error with the TTL information. // If current transaction's lock does not exist. // If the commit information of the current transaction exist. // If the current transaction has already committed. // If the current transaction has already rollbacked. // If current transaction is not prewritted before.