Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage/innobase/dict/dict0dict: add a RAII class to freeze a dict_sys_t #3529

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MaxKellermann
Copy link

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 a
    dict_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 and SRW_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

  • 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

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

These macros shall be used if there are other arguments.  Unlike the
old variants, they start with a comma.
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 a
  `dict_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` and `SRW_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).
@CLAassistant
Copy link

CLAassistant commented Sep 19, 2024

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

2 participants