@ -88,7 +88,7 @@ Status WritePreparedTxn::PrepareInternal() {
// For each duplicate key we account for a new sub-batch
prepare_batch_cnt_ = GetWriteBatch ( ) - > SubBatchCnt ( ) ;
// Having AddPrepared in the PreReleaseCallback allows in-order addition of
// prepared entries to PrepareHeap and hence enables an optimization. Refer to
// prepared entries to Prepared Heap and hence enables an optimization. Refer to
// SmallestUnCommittedSeq for more details.
AddPreparedCallback add_prepared_callback (
wpt_db_ , prepare_batch_cnt_ ,
@ -328,15 +328,23 @@ Status WritePreparedTxn::RollbackInternal() {
// CommitCache that keeps an entry evicted due to max advance and yet overlaps
// with a live snapshot around so that the live snapshot properly skips the
// entry even if its prepare seq is lower than max_evicted_seq_.
AddPreparedCallback add_prepared_callback (
wpt_db_ , ONE_BATCH , db_impl_ - > immutable_db_options ( ) . two_write_queues ) ;
WritePreparedCommitEntryPreReleaseCallback update_commit_map (
wpt_db_ , db_impl_ , GetId ( ) , prepare_batch_cnt_ , ONE_BATCH ) ;
PreReleaseCallback * pre_release_callback ;
if ( do_one_write ) {
pre_release_callback = & update_commit_map ;
} else {
pre_release_callback = & add_prepared_callback ;
}
// Note: the rollback batch does not need AddPrepared since it is written to
// DB in one shot. min_uncommitted still works since it requires capturing
// data that is written to DB but not yet committed, while
// the rollback batch commits with PreReleaseCallback.
s = db_impl_ - > WriteImpl ( write_options_ , & rollback_batch , nullptr , nullptr ,
NO_REF_LOG , ! DISABLE_MEMTABLE , & seq_used , ONE_BATCH ,
do_one_write ? & update_commit_map : nullptr ) ;
pre_release_callback ) ;
assert ( ! s . ok ( ) | | seq_used ! = kMaxSequenceNumber ) ;
if ( ! s . ok ( ) ) {
return s ;
@ -345,14 +353,14 @@ Status WritePreparedTxn::RollbackInternal() {
wpt_db_ - > RemovePrepared ( GetId ( ) , prepare_batch_cnt_ ) ;
return s ;
} // else do the 2nd write for commit
uint64_t & prepare _seq = seq_used ;
uint64_t rollback _seq = seq_used ;
ROCKS_LOG_DETAILS ( db_impl_ - > immutable_db_options ( ) . info_log ,
" RollbackInternal 2nd write prepare _seq: % " PRIu64 ,
prepare _seq) ;
" RollbackInternal 2nd write rollback _seq: % " PRIu64 ,
rollback _seq) ;
// Commit the batch by writing an empty batch to the queue that will release
// the commit sequence number to readers.
WritePreparedRollbackPreReleaseCallback update_commit_map_with_prepare (
wpt_db_ , db_impl_ , GetId ( ) , prepare _seq, prepare_batch_cnt_ ) ;
wpt_db_ , db_impl_ , GetId ( ) , rollback _seq, prepare_batch_cnt_ ) ;
WriteBatch empty_batch ;
empty_batch . PutLogData ( Slice ( ) ) ;
// In the absence of Prepare markers, use Noop as a batch separator
@ -367,6 +375,7 @@ Status WritePreparedTxn::RollbackInternal() {
if ( s . ok ( ) ) {
wpt_db_ - > RemovePrepared ( GetId ( ) , prepare_batch_cnt_ ) ;
}
wpt_db_ - > RemovePrepared ( rollback_seq , ONE_BATCH ) ;
return s ;
}