Repository navigation
MDEV-39647: Deleted Virtual secondary records might never get purged and cause table bloating - #6108
mariadb-TafzeelShams wants to merge 1 commit into
Conversation
931c1e8 to
0c6006e
Compare
0c6006e to
95dddd3
Compare
| SET GLOBAL innodb_stats_persistent = @save_stats_persistent; | ||
|
|
||
| --echo # End of 10.6 tests | ||
| --echo # End of 11.4 tests |
dr-m
left a comment
There was a problem hiding this comment.
If @Thirunarayanan ran the test with and without the fix being present, I think that this is good to go. I only have some minor nitpicks about the test itself.
| --echo # End of 10.3 tests | ||
|
|
||
| --echo # End of 10.6 tests | ||
|
|
There was a problem hiding this comment.
No tests were added in 10.4, 10.5, 10.7, 10.8, 10.9, 10.10 either. Why should 10.6 be mentioned?
There was a problem hiding this comment.
Removed
| SET GLOBAL innodb_max_purge_lag_wait=0; | ||
|
|
||
| connect (stop_purge,localhost,root,,); | ||
| START TRANSACTION WITH CONSISTENT SNAPSHOT; | ||
|
|
||
| connection default; | ||
| BEGIN; | ||
| UPDATE t1 SET value = '1B'; | ||
| UPDATE t1 SET value = '2C'; | ||
| UPDATE t1 SET value = '3D'; | ||
| UPDATE t1 SET value = '4E'; | ||
| UPDATE t1 SET value = '5F'; | ||
| UPDATE t1 SET value = '6G'; | ||
| COMMIT; | ||
|
|
||
| disconnect stop_purge; | ||
| SET GLOBAL innodb_max_purge_lag_wait=0; | ||
| CHECK TABLE t1 EXTENDED; |
There was a problem hiding this comment.
Do we really need the stop_purge connection here? There is only one transaction executed between the two SET GLOBAL innodb_max_purge_lag_wait=0.
There was a problem hiding this comment.
Removed the stop_purge connection. And checked reproducibility without the ptch.
Virtual column values are not stored in the clustered index. To check whether a secondary index record that includes a virtual column can be purged, row_purge_vc_matches_cluster() and row_vers_build_cur_vrow_low() read those values from the undo log by invoking trx_undo_prev_version_build() with TRX_UNDO_PREV_IN_PURGE. Since MDEV-24402, this read was skipped if purge_sys.end_view saw the transaction. That happens as soon as a purge batch has ended inside the undo log of the transaction, even though the remaining undo log records of the transaction have not been freed. With no values to compare, row_purge_vc_matches_cluster() assumed a match, row_purge_is_unsafe() returned true, and the delete-marked secondary index record was never removed. CHECK TABLE...EXTENDED reported "Clustered index record not found". Changes: - trx_undo_prev_version_build(): For TRX_UNDO_PREV_IN_PURGE, always read the undo log record, using purge_sys_t::view_guard::PURGE. Only purge tasks set this flag. The callers never read past the undo log record being purged, and purge only frees undo log records before purge_sys.head. - innodb.purge_secondary updates an indexed virtual column several times in one transaction, with innodb_purge_batch_size=1 so that its undo log is purged across several batches. CHECK TABLE...EXTENDED must not report any leftover secondary index records.
95dddd3 to
c8f6fb9
Compare
mariadb-TafzeelShams
left a comment
There was a problem hiding this comment.
Addressed review comments
Description
MDEV-39647: Deleted Virtual secondary records might never get purged and cause table bloating
Virtual column values are not stored in the clustered index. To check whether a secondary index record that includes a virtual column can be purged, row_purge_vc_matches_cluster() and row_vers_build_cur_vrow_low() read those values from the undo log by invoking trx_undo_prev_version_build() with TRX_UNDO_PREV_IN_PURGE.
Since MDEV-24402, this read was skipped if purge_sys.end_view saw the transaction. That happens as soon as a purge batch has ended inside the undo log of the transaction, even though the remaining undo log records of the transaction have not been freed. With no values to compare, row_purge_vc_matches_cluster() assumed a match, row_purge_is_unsafe() returned true, and the delete-marked secondary index record was never removed. CHECK TABLE...EXTENDED reported "Clustered index record not found".
Changes:
trx_undo_prev_version_build(): For TRX_UNDO_PREV_IN_PURGE, always read the undo log record, using purge_sys_t::view_guard::PURGE. Only purge tasks set this flag. The callers never read past the undo log record being purged, and purge only frees undo log records before purge_sys.head.
innodb.purge_secondary updates an indexed virtual column several times in one transaction, with innodb_purge_batch_size=1 so that its undo log is purged across several batches. CHECK TABLE...EXTENDED must not report any leftover secondary index records.
Release Notes
How can this PR be tested?
Added testcase inside
mysql-test/suite/innodb/t/purge_secondary.testto cover the changes.Basing the PR against the correct MariaDB version
mainbranch.PR quality check