@ -22,11 +22,9 @@
namespace rocksdb {
Status TransactionUtil : : CheckKeyForConflicts ( DBImpl * db_impl ,
ColumnFamilyHandle * column_family ,
const std : : string & key ,
SequenceNumber key_seq ,
bool cache_only ) {
Status TransactionUtil : : CheckKeyForConflicts (
DBImpl * db_impl , ColumnFamilyHandle * column_family , const std : : string & key ,
SequenceNumber snap_seq , bool cache_only , ReadCallback * snap_checker ) {
Status result ;
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( column_family ) ;
@ -42,7 +40,8 @@ Status TransactionUtil::CheckKeyForConflicts(DBImpl* db_impl,
SequenceNumber earliest_seq =
db_impl - > GetEarliestMemTableSequenceNumber ( sv , true ) ;
result = CheckKey ( db_impl , sv , earliest_seq , key_seq , key , cache_only ) ;
result = CheckKey ( db_impl , sv , earliest_seq , snap_seq , key , cache_only ,
snap_checker ) ;
db_impl - > ReturnAndCleanupSuperVersion ( cfd , sv ) ;
}
@ -52,8 +51,9 @@ Status TransactionUtil::CheckKeyForConflicts(DBImpl* db_impl,
Status TransactionUtil : : CheckKey ( DBImpl * db_impl , SuperVersion * sv ,
SequenceNumber earliest_seq ,
SequenceNumber key_seq , const std : : string & key ,
bool cache_only ) {
SequenceNumber snap_seq ,
const std : : string & key , bool cache_only ,
ReadCallback * snap_checker ) {
Status result ;
bool need_to_read_sst = false ;
@ -73,9 +73,9 @@ Status TransactionUtil::CheckKey(DBImpl* db_impl, SuperVersion* sv,
result = Status : : TryAgain (
" Transaction ould not check for conflicts as the MemTable does not "
" countain a long enough history to check write at SequenceNumber: " ,
ToString ( key _seq) ) ;
ToString ( snap _seq) ) ;
}
} else if ( key _seq < earliest_seq ) {
} else if ( snap _seq < earliest_seq ) {
need_to_read_sst = true ;
if ( cache_only ) {
@ -91,7 +91,7 @@ Status TransactionUtil::CheckKey(DBImpl* db_impl, SuperVersion* sv,
" max_write_buffer_number_to_maintain option could reduce the "
" frequency "
" of this error. " ,
key _seq, earliest_seq ) ;
snap _seq, earliest_seq ) ;
result = Status : : TryAgain ( msg ) ;
}
}
@ -105,11 +105,15 @@ Status TransactionUtil::CheckKey(DBImpl* db_impl, SuperVersion* sv,
if ( ! ( s . ok ( ) | | s . IsNotFound ( ) | | s . IsMergeInProgress ( ) ) ) {
result = s ;
} else if ( found_record_for_key & & ( seq > key_seq ) ) {
// Write Conflict
} else if ( found_record_for_key ) {
bool write_conflict = snap_checker = = nullptr
? snap_seq < seq
: ! snap_checker - > IsCommitted ( seq ) ;
if ( write_conflict ) {
result = Status : : Busy ( ) ;
}
}
}
return result ;
}