← Back to Pull requests

MDEV-37347 SKIP LOCKED at lock wait timeout 0 rolls back the transaction #6214

Open
unknown opened this pull request with 265 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 24, 2026 21:35 UTC
Author

https://jira.mariadb.org/browse/MDEV-37347

Description

With innodb_lock_wait_timeout=0, lock_rec_enqueue_waiting() does not enqueue a waiting lock request. It stores DB_LOCK_WAIT_TIMEOUT in trx->error_state and returns it. For SKIP LOCKED, row_search_mvcc() turns the return value into "skip this row", but it left trx->error_state set.

At the end of the statement, innobase_commit() calls end_of_statement(), which treats a set trx->error_state as a failed statement: it rolls back the whole transaction and returns error 1. The server reports this as ER_ERROR_DURING_COMMIT (Got error 1 "Operation not permitted" during COMMIT), after the result set has already been sent. Inside BEGIN or with autocommit=0, the earlier changes of the transaction are lost.

The fix clears trx->error_state in the two places where row_search_mvcc() skips a locked record under SKIP LOCKED: after sel_set_rec_lock(), and after the lookup of the clustered index record from a secondary index.

Behavior changes

With innodb_lock_wait_timeout=0, SELECT ... FOR UPDATE SKIP LOCKED and LOCK IN SHARE MODE SKIP LOCKED skip the locked rows without an error, as they do with any other timeout, and the transaction keeps its earlier changes.

How can this PR be tested?

A new section of innodb.skip_locked_nowait holds a lock on one row and, from a second connection with innodb_lock_wait_timeout=0, inserts two rows and then runs SKIP LOCKED as a point lookup and a range scan on the primary key, and as a scan of a secondary index that locks the clustered index record. It checks SHOW WARNINGS after each statement and the inserted rows after COMMIT. Without the fix, the test fails at the point lookup with ER_ERROR_DURING_COMMIT (1180): Got error 1 "Operation not permitted" during COMMIT.

On a debug build, innodb,innodb_gis: Completed: All 675 tests were successful. main.locking_clause passes too.

Basing the PR against the correct MariaDB version


  • This is a bug fix and the PR is based against the earliest branch in which the bug can be reproduced
  • Diff: 265 lines (+198 / -67) across 3 files Reviewer: gkodinov Review duration: 9161m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 265 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.334
    Real PR Conversation Timeline
    1 comments
    "Review active on #6214"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.3% (MEDIUM) · Higher = larger blast radius
    39.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.0% · Safe to merge
    21.0%
    Repository