// TxnHeartBeat implements the MVCCStore interface.
TxnHeartBeat implements the MVCCStore interface.
// TxnHeartBeat implements the MVCCStore interface .
func (mvcc *MVCCRocksDB) TxnHeartBeat(primaryKey []byte, startTS uint64, adviseTTL uint64) (uint64, error) {
	mvcc.mu.Lock()
	defer mvcc.mu.Unlock()
	startKey := mvccEncode(primaryKey, lockVer)
	iter := newIterator(mvcc.db, &gorocksdb.Range{
		Start: startKey,
	})
	defer iter.Close()
	if iter.Valid() {
		dec := lockDecoder{
			expectKey: primaryKey,
		}
		ok, err := dec.Decode(iter)
		if err != nil {
			return 0, errors.Trace(err)
		}
		if ok && dec.lock.startTS == startTS {
			if !bytes.Equal(dec.lock.primary, primaryKey) {
				return 0, errors.New("txnHeartBeat on non-primary key, the code should not run here")
			}
			lock := dec.lock
			batch := gorocksdb.NewWriteBatch()
			if adviseTTL > lock.ttl {
				lock.ttl = adviseTTL
				writeKey := mvccEncode(primaryKey, lockVer)
				writeValue, err := lock.MarshalBinary()
				if err != nil {
					return 0, errors.Trace(err)
				}
				batch.Put(writeKey, writeValue)
				if err = mvcc.db.Write(gorocksdb.NewDefaultWriteOptions(), batch); err != nil {
					return 0, errors.Trace(err)
				}
			}
			return lock.ttl, nil
		}
	}
	return 0, errors.New("lock doesn't exist")
}
func ( mvcc * MVCCRocksDB ) TxnHeartBeat ( primaryKey [ ] byte , startTS uint64 , adviseTTL uint64 ) ( uint64 , error ) { mvcc . mu . Lock ( ) defer mvcc . mu . Unlock ( ) startKey := mvccEncode ( primaryKey , lockVer ) iter := newIterator ( mvcc . db , & gorocksdb . Range { Start : startKey , } ) defer iter . Close ( ) if iter . Valid ( ) { dec := lockDecoder { expectKey : primaryKey , } ok , err := dec . Decode ( iter ) if err != nil { return 0 , errors . Trace ( err ) } if ok && dec . lock . startTS == startTS { if ! bytes . Equal ( dec . lock . primary , primaryKey ) { return 0 , errors . New ( " " ) } lock := dec . lock batch := gorocksdb . NewWriteBatch ( ) if adviseTTL > lock . ttl { lock . ttl = adviseTTL writeKey := mvccEncode ( primaryKey , lockVer ) writeValue , err := lock . MarshalBinary ( ) if err != nil { return 0 , errors . Trace ( err ) } batch . Put ( writeKey , writeValue ) if err = mvcc . db . Write ( gorocksdb . NewDefaultWriteOptions ( ) , batch ) ; err != nil { return 0 , errors . Trace ( err ) } } return lock . ttl , nil } } return 0 , errors . New ( " " ) }
TxnHeartBeat implements the MVCCStore interface.
TxnHeartBeat implements the MVCCStore interface .
// Increase the ttl of this transaction.