Conversation
|
Hi @pranavktiwari, Thank you for the patch! Now I see that change for MDL_BIT has negative effect on performance which is unwanted. I'd better tell in the description that it is investigation task and should be evaluated for push. Nonetheless, if we rework It seems that I cannot recognize the changes for the second part of the ticket (about |
There was a problem hiding this comment.
Pull request overview
This PR reworks MDL enum constant values so that 0 represents an uninitialized MDL state (instead of mapping to real lock types), and updates related mappings/output so metadata lock reporting continues to work.
Changes:
- Shifted
enum_mdl_type/ backup-stage lock constants soMDL_NOT_INITIALIZEDbecomes0. - Introduced
MDL_key::NOT_INITIALIZED=0namespace and updated handlers/mappings accordingly. - Updated incompatibility matrices, metadata-lock name tables, and adjusted mysql-test expected results.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| sql/sp.h | Adds handling for MDL_key::NOT_INITIALIZED in namespace→handler switch. |
| sql/mdl.h | Updates MDL type and namespace enums and shifts backup lock constants. |
| sql/mdl.cc | Adds NOT_INITIALIZED PSI stage entry, pads name tables, and pads incompatibility arrays. |
| plugin/metadata_lock_info/metadata_lock_info.cc | Adds “Not initialised” entry to namespace name table. |
| mysql-test/main/mdl_sync.result | Updates expected output ordering for MDL metadata_lock_info. |
| mysql-test/main/mdl.result | Updates expected output ordering for MDL metadata_lock_info. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sql/mdl.cc
Outdated
|
|
||
| PSI_stage_info MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]= | ||
| { | ||
| {0, "Not initilised", 0}, |
There was a problem hiding this comment.
The new stage name string has a spelling error: "Not initilised". This ends up visible in processlist/performance schema stage output; please fix the typo (and ideally keep spelling consistent with the information_schema.metadata_lock_info strings).
| {0, "Not initilised", 0}, | |
| {0, "Not initialised", 0}, |
sql/mdl.cc
Outdated
|
|
||
| static const LEX_STRING lock_types[]= | ||
| { | ||
| {}, |
There was a problem hiding this comment.
The 0th entry in lock_types is now an empty LEX_STRING (str==NULL). If any code path ends up calling get_mdl_lock_name()/get_type_name() with MDL_NOT_INITIALIZED (e.g., debug logging on an uninitialized MDL_request), this can lead to undefined behavior when printing "%s". Consider providing a real name like "MDL_NOT_INITIALIZED" instead of an empty initializer to keep it safe and debuggable.
| {}, | |
| { C_STRING_WITH_LEN("MDL_NOT_INITIALIZED") }, |
sql/mdl.cc
Outdated
|
|
||
| static const LEX_STRING backup_lock_types[]= | ||
| { | ||
| {}, |
There was a problem hiding this comment.
Same issue as lock_types[]: backup_lock_types[0] is now an empty LEX_STRING (str==NULL). If a backup-namespace MDL_request/ticket is ever inspected or logged with type==0, printing the name can dereference/format a NULL string. Using an explicit "MDL_NOT_INITIALIZED" (or similar) entry at index 0 would avoid surprises.
| {}, | |
| { C_STRING_WITH_LEN("MDL_BACKUP_NOT_INITIALIZED") }, |
Introduce MDL_NOT_INITIALIZED=0 in enum_mdl_type and NOT_INITIALIZED=0 in enum_mdl_namespace. Adjust all dependent structures accordingly and shift MDL_BACKUP_* enum values by +1. Shifting enum values changes the result of hash_value(). Since MDL locks are stored in a Split-Ordered List (lock-free hash table) ordered by my_reverse_bits(hash_value()), this alters the iteration order observed in metadata_lock_info. Remove the previous workaround that preserved old hash values by adjusting enums during hashing. Instead, update result files to reflect the new iteration order, as it is an implementation detail and does not affect MDL correctness.
4e53799 to
eea7448
Compare
fixes MDEV-39184
Problem:
MDL constants values of 0 assign some default values (MDL_INTENTION_EXCLUSIVE, BACKUP) before MDL_REQUEST_INIT(). That does not make sense if MDL_REQUEST_INIT() was not called. Please rework the values of 0 into (MDL_NOT_INITIALIZED, NOT_INITIALIZED). Described by these comments in the code:
Fix
1- Increment all values in enum_mdl_type by 1.
2- Add a 0 at the start of the incompatibility arrays so the enum indices continue to match their corresponding bitmasks.
This ensures that uninitialized MDL constants are correctly handled while preserving existing bitmask mappings.