Skip to content

MDEV-21423 - lock-free trx_sys get performance regression cause by lf_find and ut_delay#5043

Open
svoj wants to merge 1 commit intoMariaDB:mainfrom
svoj:pr-main-MDEV-21423
Open

MDEV-21423 - lock-free trx_sys get performance regression cause by lf_find and ut_delay#5043
svoj wants to merge 1 commit intoMariaDB:mainfrom
svoj:pr-main-MDEV-21423

Conversation

@svoj
Copy link
Copy Markdown
Contributor

@svoj svoj commented May 5, 2026

TBD

@svoj svoj requested a review from dr-m May 5, 2026 22:10
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new rw_trx_ids_t class to manage read-write transaction IDs and serialization numbers, moving them from the hash elements into a centralized vector within the transaction system. This involves significant updates to transaction registration, deregistration, and snapshotting logic across InnoDB. Feedback highlights a critical thread-safety issue where the ids vector is accessed without a read lock during potential reallocations, which could lead to memory corruption. Additionally, the use of memset to initialize a synchronization primitive was identified as unsafe and should be removed in favor of the standard initialization call.

Comment thread storage/innobase/include/trx0sys.h
Comment thread storage/innobase/include/trx0sys.h Outdated
Comment thread storage/innobase/include/trx0sys.h Outdated
Comment thread storage/innobase/include/trx0sys.h Outdated
Comment thread storage/innobase/include/trx0sys.h Outdated
Comment thread storage/innobase/log/log0log.cc Outdated
@svoj svoj force-pushed the pr-main-MDEV-21423 branch from 3b998f0 to 6d2f280 Compare May 6, 2026 07:11
Comment thread storage/innobase/include/trx0sys.h Outdated
Comment thread storage/innobase/include/trx0sys.h
Comment thread storage/innobase/include/trx0sys.h
Comment thread storage/innobase/include/trx0sys.h
Comment thread storage/innobase/include/trx0sys.h
Comment thread storage/innobase/include/trx0sys.h Outdated
Comment thread storage/innobase/include/trx0sys.h
Comment thread storage/innobase/include/trx0trx.h Outdated
@svoj svoj force-pushed the pr-main-MDEV-21423 branch from 6d2f280 to 0de23ce Compare May 6, 2026 12:18
@svoj svoj force-pushed the pr-main-MDEV-21423 branch from 0de23ce to ac20be7 Compare May 6, 2026 14:21
Copy link
Copy Markdown
Contributor

@dr-m dr-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very promising. The reason why I won’t give an approval yet is that I didn’t review all details of this thoroughly, especially around startup and shutdown.

This needs to be tested, both for performance and stability. Please coordinate with the testers on this.

Comment on lines +632 to +633
/** trx_sys.rw_trx_ids index, protected by mutex */
uint32_t rw_trx_ids_slot;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really protected by trx_t::mutex as the comment claims, or by trx_sys.rw_trx_ids.latch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants