Skip to content

MDEV-25964: Unexpected bypass of lock#5257

Open
DaveGosselin-MariaDB wants to merge 1 commit into
10.11from
10.11-mdev-25964-lock-bypass
Open

MDEV-25964: Unexpected bypass of lock#5257
DaveGosselin-MariaDB wants to merge 1 commit into
10.11from
10.11-mdev-25964-lock-bypass

Conversation

@DaveGosselin-MariaDB

Copy link
Copy Markdown
Member

When an uncommitted transaction inserts rows into a table and another statement locks rows in the same table (SELECT ... FOR UPDATE) while computing a MIN or MAX, then:

  1. In a Debug build, the server aborts on an assertion
  2. In a Release build, the server returns wrong results These errors occur because, while reading a group of rows for computing a MAX, the transaction timeout error was swallowed.

Under the scenario described above and captured in the new test at this commit, QUICK_GROUP_MIN_MAX_SELECT::next_max() emits a lock timeout error during QUICK_GROUP_MIN_MAX_SELECT::get_next() but the error was suppressed if we computed a MIN.

Keep the MAX result when the MIN call succeeded but the MAX result failed, so the error propagates to the client.

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

Copy link
Copy Markdown

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 addresses an issue where handler errors (such as lock wait timeouts) returned by next_max() in QUICK_GROUP_MIN_MAX_SELECT::get_next() were either causing crashes in Debug builds due to an assertion or being swallowed in Release builds. The changes ensure proper error propagation and add test coverage. The review feedback correctly identifies that the updated assertion is still too restrictive and could cause crashes for other transient errors like deadlocks or query interruptions, suggesting a more robust assertion condition.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread sql/opt_range.cc Outdated
@DaveGosselin-MariaDB DaveGosselin-MariaDB force-pushed the 10.11-mdev-25964-lock-bypass branch from 5c67c77 to 146032b Compare June 18, 2026 17:45
When an uncommitted transaction inserts rows into a table and
another statement locks rows in the same table (SELECT ... FOR UPDATE)
while computing a MIN or MAX, then:
  1. In a Debug build, the server aborts on an assertion
  2. In a Release build, the server returns wrong results
These errors occur because, while reading a group of rows for computing
a MAX, the transaction timeout error was swallowed.

Under the scenario described above and captured in the new test at this
commit, QUICK_GROUP_MIN_MAX_SELECT::next_max() emits a lock timeout error
during QUICK_GROUP_MIN_MAX_SELECT::get_next() but the error was suppressed
if we computed a MIN.

Keep the MAX result when the MIN call succeeded but the MAX result
failed, so the error propagates to the client.  Now that we expect an error
to propagate on error computing a MAX, drop the assertion.
@DaveGosselin-MariaDB DaveGosselin-MariaDB force-pushed the 10.11-mdev-25964-lock-bypass branch from 146032b to b284321 Compare June 18, 2026 18:28
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.

1 participant