@ -88,7 +88,7 @@ Status WritePreparedTxn::PrepareInternal() {
// For each duplicate key we account for a new sub-batch
// For each duplicate key we account for a new sub-batch
prepare_batch_cnt_ = GetWriteBatch ( ) - > SubBatchCnt ( ) ;
prepare_batch_cnt_ = GetWriteBatch ( ) - > SubBatchCnt ( ) ;
// Having AddPrepared in the PreReleaseCallback allows in-order addition of
// 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.
// SmallestUnCommittedSeq for more details.
AddPreparedCallback add_prepared_callback (
AddPreparedCallback add_prepared_callback (
wpt_db_ , prepare_batch_cnt_ ,
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
// 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
// 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_.
// 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 (
WritePreparedCommitEntryPreReleaseCallback update_commit_map (
wpt_db_ , db_impl_ , GetId ( ) , prepare_batch_cnt_ , ONE_BATCH ) ;
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
// 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
// DB in one shot. min_uncommitted still works since it requires capturing
// data that is written to DB but not yet committed, while
// data that is written to DB but not yet committed, while
// the rollback batch commits with PreReleaseCallback.
// the rollback batch commits with PreReleaseCallback.
s = db_impl_ - > WriteImpl ( write_options_ , & rollback_batch , nullptr , nullptr ,
s = db_impl_ - > WriteImpl ( write_options_ , & rollback_batch , nullptr , nullptr ,
NO_REF_LOG , ! DISABLE_MEMTABLE , & seq_used , ONE_BATCH ,
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 ) ;
assert ( ! s . ok ( ) | | seq_used ! = kMaxSequenceNumber ) ;
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
return s ;
return s ;
@ -345,14 +353,14 @@ Status WritePreparedTxn::RollbackInternal() {
wpt_db_ - > RemovePrepared ( GetId ( ) , prepare_batch_cnt_ ) ;
wpt_db_ - > RemovePrepared ( GetId ( ) , prepare_batch_cnt_ ) ;
return s ;
return s ;
} // else do the 2nd write for commit
} // 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 ,
ROCKS_LOG_DETAILS ( db_impl_ - > immutable_db_options ( ) . info_log ,
" RollbackInternal 2nd write prepare _seq: % " PRIu64 ,
" RollbackInternal 2nd write rollback _seq: % " PRIu64 ,
prepare _seq) ;
rollback _seq) ;
// Commit the batch by writing an empty batch to the queue that will release
// Commit the batch by writing an empty batch to the queue that will release
// the commit sequence number to readers.
// the commit sequence number to readers.
WritePreparedRollbackPreReleaseCallback update_commit_map_with_prepare (
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 ;
WriteBatch empty_batch ;
empty_batch . PutLogData ( Slice ( ) ) ;
empty_batch . PutLogData ( Slice ( ) ) ;
// In the absence of Prepare markers, use Noop as a batch separator
// In the absence of Prepare markers, use Noop as a batch separator
@ -367,6 +375,7 @@ Status WritePreparedTxn::RollbackInternal() {
if ( s . ok ( ) ) {
if ( s . ok ( ) ) {
wpt_db_ - > RemovePrepared ( GetId ( ) , prepare_batch_cnt_ ) ;
wpt_db_ - > RemovePrepared ( GetId ( ) , prepare_batch_cnt_ ) ;
}
}
wpt_db_ - > RemovePrepared ( rollback_seq , ONE_BATCH ) ;
return s ;
return s ;
}
}