@ -1712,10 +1712,17 @@ Status BlobDBImpl::GCFileAndUpdateLSM(const std::shared_ptr<BlobFile>& bfptr,
gcstats - > blob_count + + ;
bool del_this = false ;
bool reloc_this = false ;
// TODO(yiwu): The following logic should use GetForUpdate() from
// optimistic transaction to check if the key is current, otherwise
// there can be another writer sneak in between sequence number of
// and the deletion.
// this particular TTL has expired
if ( no_relocation_ttl | | ( has_ttl & & tt > record . GetTTL ( ) ) ) {
del_this = true ;
} else {
} else if ( ! first_gc ) {
SequenceNumber seq = kMaxSequenceNumber ;
bool found_record_for_key = false ;
SuperVersion * sv = db_impl_ - > GetAndRefSuperVersion ( cfd ) ;
@ -1726,8 +1733,8 @@ Status BlobDBImpl::GCFileAndUpdateLSM(const std::shared_ptr<BlobFile>& bfptr,
}
Status s1 = db_impl_ - > GetLatestSequenceForKey (
sv , record . Key ( ) , false , & seq , & found_record_for_key ) ;
if ( s1 . IsNotFound ( ) | | ( ! found_record_for_key | | seq ! = record . GetSN ( ) ) ) {
del _this = true ;
if ( found_record_for_key & & seq = = record . GetSN ( ) ) {
reloc _this = true ;
}
db_impl_ - > ReturnAndCleanupSuperVersion ( cfd , sv ) ;
}
@ -1749,11 +1756,9 @@ Status BlobDBImpl::GCFileAndUpdateLSM(const std::shared_ptr<BlobFile>& bfptr,
gcstats - > overrided_while_delete + + ;
}
delete txn ;
continue ;
} else if ( first_gc ) {
continue ;
}
if ( reloc_this ) {
if ( ! newfile ) {
// new file
std : : string reason ( " GC of " ) ;
@ -1806,9 +1811,9 @@ Status BlobDBImpl::GCFileAndUpdateLSM(const std::shared_ptr<BlobFile>& bfptr,
write_options_ , OptimisticTransactionOptions ( ) , nullptr ) ;
txn - > Put ( cfh , record . Key ( ) , index_entry ) ;
Status s1 = txn - > Commit ( ) ;
// chances that this Put will fail is low. If it fails, it would be becaus e
// a new version of the key came in at this time, which will override
// the current version being iterated on.
// chances that this Put will fail is low. If it fails, it would be
// because a new version of the key came in at this time, which will
// override the current version being iterated on.
if ( s1 . IsBusy ( ) ) {
ROCKS_LOG_INFO ( db_options_ . info_log ,
" Optimistic transaction failed: %s put bn: % " PRIu32 ,
@ -1821,6 +1826,7 @@ Status BlobDBImpl::GCFileAndUpdateLSM(const std::shared_ptr<BlobFile>& bfptr,
}
delete txn ;
}
}
if ( gcstats - > newfile ) total_blob_space_ + = newfile - > file_size_ ;