Skip to content

Rework MDL enum constants values#4912

Open
pranavktiwari wants to merge 1 commit into12.3from
12.3-MDEV-39184
Open

Rework MDL enum constants values#4912
pranavktiwari wants to merge 1 commit into12.3from
12.3-MDEV-39184

Conversation

@pranavktiwari
Copy link
Copy Markdown

@pranavktiwari pranavktiwari commented Apr 7, 2026

fixes MDEV-39184

Problem:

MDL tests results ordering is not deterministic.

Fix

Added --sorted_result to the MDL tests to ensure deterministic ordering of metadata_lock_info output. Since MDL lock iteration order depends on hash_value() and underlying Split-Ordered List behavior, it may vary with
internal changes such as enum value shifts.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 7, 2026

CLA assistant check
All committers have signed the CLA.

@midenok
Copy link
Copy Markdown
Contributor

midenok commented Apr 8, 2026

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 enum_mdl_type into bitmask values we would not need MDL_BIT() at all. What other problems occur if we try that?

It seems that I cannot recognize the changes for the second part of the ticket (about enum_mdl_namespace). Is it feasible to do these changes? Can you try to do it on the minimal set of code, without plugins and minor storage engines?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 so MDL_NOT_INITIALIZED becomes 0.
  • Introduced MDL_key::NOT_INITIALIZED=0 namespace 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.

Comment thread sql/mdl.cc Outdated
Comment thread sql/mdl.cc Outdated
Comment thread sql/mdl.cc Outdated
Comment thread sql/mdl.cc
Comment thread sql/mdl.h
Comment thread sql/mdl.h
@pranavktiwari pranavktiwari force-pushed the 12.3-MDEV-39184 branch 2 times, most recently from eea7448 to 7bca7c5 Compare April 16, 2026 15:59
@midenok midenok requested a review from Copilot April 17, 2026 09:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sql/mdl.h Outdated
Comment thread sql/mdl.cc
Comment on lines 101 to 104
PSI_stage_info MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]=
{
{0, "Not initialised", 0},
{0, "Waiting for backup lock", 0},
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

MDL_key::enum_mdl_namespace now has NOT_INITIALIZED (index 0) and a corresponding PSI stage entry was added. However, wsrep_get_mdl_namespace_name() (later in this file) does not handle MDL_key::NOT_INITIALIZED, so wsrep debug output will report the namespace as "UNKNOWN" for this new value. Add an explicit case for NOT_INITIALIZED to keep diagnostics accurate (and to avoid -Wswitch-enum warnings if enabled).

Copilot uses AI. Check for mistakes.
Added --sorted_result to the MDL tests to ensure deterministic ordering
of metadata_lock_info output. Since MDL lock iteration order depends on
hash_value() and underlying Split-Ordered List behavior, it may vary with
internal changes such as enum value shifts.
Comment thread sql/mdl.h
TODO (newbie): should be MDL_NOT_INITIALIZED= 0, as it is strange
that not-inited request has MDL_INTENTION_EXCLUSIVE.
Must fix tests, as at least mysql_rm_table_no_locks() depends on this.
*/
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.

This comment should be removed too.

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.

5 participants