While reviewing some code to prepare for
MDEV-24402, I came across the following.
In the case where the purge coordinator task invokes trx_purge_remove_log_hdr() outside of trx_purge_free_segment(), it would be possible to free the undo log page, provided that nothing was appended to the page after the purged records.
Undo log pages may contain records for many unrelated transactions. If no "reuse of cached undo pages" took place, we could simply free the undo page. This could avoid some page writes and improve the performance of backup and recovery. It could also avoid unnecessary growth of the system tablespace or the temporary tablespace when they store undo log pages.