Skip to content

Add retry logic for instant DDL on lock wait timeout#1651

Merged
meiji163 merged 2 commits intogithub:masterfrom
yosefbs:retry-instant-ddl-on-lock-timeout
Mar 18, 2026
Merged

Add retry logic for instant DDL on lock wait timeout#1651
meiji163 merged 2 commits intogithub:masterfrom
yosefbs:retry-instant-ddl-on-lock-timeout

Conversation

@yosefbs
Copy link
Contributor

@yosefbs yosefbs commented Mar 18, 2026

A Pull Request should be associated with an Issue.

Related issue: #1650

Further notes in https://github.com/github/gh-ost/blob/master/.github/CONTRIBUTING.md
Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR

Description

This PR adds retry logic for instant DDL when a lock wait timeout (MySQL errno 1205) occurs. When a long-running transaction holds a metadata lock, the instant DDL attempt may fail with a lock wait timeout. Instead of failing immediately, the operation is now retried up to 5 times with linear backoff (5s, 10s, 15s, 20s between attempts). Non-timeout errors such as ALGORITHM=INSTANT is not supported still return immediately without retrying.

A new retryOnLockWaitTimeout function is introduced separately from the existing retryOperation in the migrator, because it requires error-discriminating behavior (only retry on errno 1205) and should not trigger PanicAbort on failure.

Unit tests cover all branches: success on first attempt, retry then succeed, non-retryable MySQL error, non-MySQL error, and retry exhaustion.

In case this PR introduced Go code changes:

  • [V] contributed code is using same conventions as original code
  • [] script/cibuild returns with no formatting errors, build errors or unit test errors.

ybs-me added 2 commits March 18, 2026 22:58
When attempting instant DDL, a lock wait timeout (errno 1205) may occur
if a long-running transaction holds a metadata lock. Rather than failing
immediately, retry the operation up to 5 times with linear backoff.
Non-timeout errors (e.g. ALGORITHM=INSTANT not supported) still return
immediately without retrying.
@meiji163
Copy link
Contributor

Thanks for the PR!

@meiji163 meiji163 merged commit b9652c3 into github:master Mar 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants