File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
crates/datastore/src/locking_tx_datastore Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1204,6 +1204,19 @@ impl MutTxId {
1204
1204
) ;
1205
1205
let reducer = self . ctx . into_reducer_name ( ) ;
1206
1206
1207
+ // If the transaction didn't consume an offset (i.e. it was empty),
1208
+ // report the previous offset.
1209
+ //
1210
+ // Note that technically the tx could have run against an empty database,
1211
+ // in which case we'd wrongly return zero (a non-existent transaction).
1212
+ // This doesn not happen in practice, however, as [RelationalDB::set_initialized]
1213
+ // creates a transaction.
1214
+ let tx_offset = if tx_offset == self . committed_state_write_lock . next_tx_offset {
1215
+ tx_offset. saturating_sub ( 1 )
1216
+ } else {
1217
+ tx_offset
1218
+ } ;
1219
+
1207
1220
( tx_offset, tx_data, tx_metrics, reducer)
1208
1221
}
1209
1222
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ impl TxId {
96
96
pub ( super ) fn release ( self ) -> ( TxOffset , TxMetrics , String ) {
97
97
// A read tx doesn't consume `next_tx_offset`, so subtract one to obtain
98
98
// the offset that was visible to the transaction.
99
+ //
99
100
// Note that technically the tx could have run against an empty database,
100
101
// in which case we'd wrongly return zero (a non-existent transaction).
101
102
// This doesn not happen in practice, however, as [RelationalDB::set_initialized]
You can’t perform that action at this time.
0 commit comments