Bug #107807 transaction rollback optimize
Submitted: 8 Jul 2022 4:39 Modified: 12 Aug 2022 11:39
Reporter: alex xing (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:8.0.19 OS:Any
Assigned to: CPU Architecture:Any

[8 Jul 2022 4:39] alex xing
Description:
As we all kown, when transaction rollback, it need clear undo(trx_UNDO_TRUNCATE_END_func).And this is a synchronous behavior. 
But the transaction is large, the rollback time will be increased.  
Since the undo that needs to be reclaimed will be marked when the transaction is eventually rolled back。
So, is it possible to make this behavior asynchronous, just like trx commit.

The undo reclaim code flow is as follows
trx_roll_pop_top_rec_of_trx-->trx_roll_pop_top_rec_of_trx_low-->trx_roll_try_truncate-->trx_undo_truncate_end

How to repeat:
just read code

Suggested fix:
if large transaction , make this behavior asynchronous, just like trx commit.
[8 Jul 2022 11:44] MySQL Verification Team
Hi Mr. xing,

Thank you for your performance enhancement request.

However, we do not find that your request is adequately documented.

Having ROLLBACK run asynchronously would raise a very large number of problems. Among those we would like to mention the following ones:

* clearing of all types of locks

* clearing of undo logs

* clearing of redo logs

* clearing of the changes that would impact sessions that are run in the READ_UNCOMMITTED

* several others ....

Hence, ROLLBACK currently can not be run asynchronously, as it would impact heavily the behaviour of the transactional engine. This could lead to the strange results in all current implementations.

There is currently no solution for those, but if you come up with a complete solution, we would very much like to hear about it .......
[11 Jul 2022 2:01] alex xing
I just mean rollback data and clear all types of locks synchronously and clear undo  asynchronously in purge_sys
[11 Jul 2022 11:53] MySQL Verification Team
Sorry, but a performance improvement request has to be much better documented and justified.

Asynchronous clearing of the undo log would make problems with some of the isolation levels. You have not provided a solution for that issue.
[12 Aug 2022 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".