MDEV-37347 SKIP LOCKED at lock wait timeout 0 rolls back the transaction #6214
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
gkodinov
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 storesDB_LOCK_WAIT_TIMEOUTintrx->error_stateand returns it. ForSKIP LOCKED,row_search_mvcc()turns the return value into "skip this row", but it lefttrx->error_stateset.At the end of the statement,
innobase_commit()callsend_of_statement(), which treats a settrx->error_stateas a failed statement: it rolls back the whole transaction and returns error 1. The server reports this asER_ERROR_DURING_COMMIT(Got error 1 "Operation not permitted" during COMMIT), after the result set has already been sent. InsideBEGINor withautocommit=0, the earlier changes of the transaction are lost.The fix clears
trx->error_statein the two places whererow_search_mvcc()skips a locked record underSKIP LOCKED: aftersel_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 LOCKEDandLOCK IN SHARE MODE SKIP LOCKEDskip 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_nowaitholds a lock on one row and, from a second connection withinnodb_lock_wait_timeout=0, inserts two rows and then runsSKIP LOCKEDas 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 checksSHOW WARNINGSafter each statement and the inserted rows afterCOMMIT. Without the fix, the test fails at the point lookup withER_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_clausepasses too.Basing the PR against the correct MariaDB version