server
server copied to clipboard
MDEV-34986: storage/innobase/dict/dict0dict: add a RAII class to freeze a dict_sys_t
https://jira.mariadb.org/browse/MDEV-34986
Description
This replaces a lot of manual freeze() and unfreeze() call. Doing it with RAII is safer and easier.
I did not replace all freeze()/unfreeze() pairs because some callers unfreeze and re-freeze in the middle of a scope. Sometimes, adding a new scope can be added just for such a RAII object. Refactoring that can be done later.
Notes:
-
Instead of using the global variable
dict_sys
, I decided to pass adict_sys_t
reference parameter, because I believe it will be necessary to eliminate that global variable eventually (in order to have a per-catalog instance). Hard-coding this global variable here would generate identical (not better) machine code and would be a step in the wrong direction. -
The new macros
SRW_LOCK_ARGS2
andSRW_LOCK_CALL2
were necessary because this is the first time those debug-only parameters are forwarded from a function that has more parameters (i.e. the dict_sys_t reference).
Release Notes
Nothing. Internal code change only with no runtime effect.
How can this PR be tested?
No runtime effect.
Basing the PR against the correct MariaDB version
- [X] This is a new feature or a refactoring, and the PR is based against the
main
branch. - [ ] This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.
PR quality check
- [X] I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
- [X] For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.