When sweep succesfully finished its work it advance OIT up to the value of OST that was recorded at sweep start time.
If while sweep running there was started more than sweep_interval transaction, it could be that new OIT value again more than sweep_interval less than new OST value.
But new OIT is not pointed to the rolled back transaction and in fact it is recalculated by the first transaction which is started after sweep advances OIT.
The bug is that transaction_start used OIT value from header page when calculates sweep gap while it is more correct to use just recalculated value of OIT.
1. tx 1000 was rolled back. Next tx calculated OIT as 1000 and it is stuck value.
2. tx 21001 calculated following numbers:
OIT = 1000, OST = 21000, Next = 21001
3. auto sweep is started. Save_OST = 21000
4. while sweep is running there are new 30000 tx started and committed
5. sweep is done with gc and about to advance OIT
OIT = 1000, OST = 51000, Next = 51001
6. sweep advanced OIT up to the Save_OST, i.e. 21000
7. new tx is started and obtained following numbers:
tra_oldest = 21000
tra_oldest_active = 51002
tra_number = 51002
also it is recalculated new oldest tx number and it is 51001
8. condition below is true
tra_oldest_active - tra_oldest > sweep_interval
therefore sweep is started again
9. when sweep is started database header page will contain OIT = 51001