Migration hangs when --attempt-instant-ddl succeeds
メンテナーはふだん 10 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
調査の方向性
Start with Migrate() in go/logic/migrator.go, where the instant-DDL branch returns without reading ghostTableMigrated, then follow onChangelogStateEvent and notifyListeners to see where listenersMutex is held during the blocking send. The binlog side is shouldDecodeRowsEvent in the event streamer, reached through BinlogSyncer.Close() in finalCleanup. Done means the instant-DDL success path returns without hanging, with a test covering that short-circuit.
索引モデルが issue の本文から書いたものです。
説明
Overview
A migration run with --attempt-instant-ddl against a server that can apply the
ALTER instantly applies it, logs Success! table ... migrated instantly, and then
never returns. gh-ost hangs until it is killed.
Reproduced on master (dd44453f) and on v1.1.11.
Why
Migrate() short-circuits on the instant-DDL path: on success it calls
finalCleanup(), runs the OnSuccess hook and returns, so it never reads
<-mgtr.ghostTableMigrated.
Three goroutines then form a cycle:
-
The changelog listener parks on the
GhostTableMigratedsend in
onChangelogStateEvent.ghostTableMigratedis unbuffered and the
instant-DDL path never reads it, so the send blocks. It is wrapped in
base.SendWithContext, which only unblocks on context cancellation — and
nothing cancels the context here, precisely becauseMigrate()has not
returned. The listener is invoked fromnotifyListeners, which holds
listenersMutexacross the synchronous call, so the mutex stays held for as
long as the send is parked. -
The binlog parser goroutine (go-mysql's
BinlogSyncer.onStream) calls
EventsStreamer.shouldDecodeRowsEventthroughRowsEventDecodeFuncand
blocks taking that samelistenersMutex. -
BinlogSyncer.Close(), reached fromfinalCleanup()→
EventsStreamer.Close(), ends inb.wg.Wait()and waits for that parser
goroutine, which is never coming back.
Step 2 is what makes the cycle reachable. shouldDecodeRowsEvent was introduced
by #1699 ("Don't parse binlog events of unrelated tables", first released in
v1.1.11); it put listenersMutex on the binlog parser's goroutine, so a listener
parked while holding that mutex now stalls the parser directly, and with it
BinlogSyncer.Close().
--attempt-instant-ddl defaults to off and the short-circuit has no test
coverage, which is presumably why this has not been reported before. We hit it in
a downstream consumer that passes the flag for every migration, where every ALTER
MySQL could apply instantly hung.
Reproduction
Any instant-applicable ALTER on MySQL 8.0 with the flag set, e.g.
gh-ost --host=... --database=test --table=testing \
--alter='ADD COLUMN author varchar(255)' \
--attempt-instant-ddl --allow-on-master --execute
The column is added, Success! ... migrated instantly is logged, and the process
does not exit.
Fix
PR to follow: scope listenersMutex to the listener lookup in notifyListeners,
and give ghostTableMigrated a one-slot buffer.
- 主要言語
- Go
- スター
- 13.6k
- フォーク
- 1.4k
- 平均マージ
- 9日 19時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/gh-ost のほかの issue
-
`--resume` without `--execute` drops the ghost table it correctly skipped altering対応中かも @ajm188 が 55 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 10 日以内に返信
-
[Suggestion] Apply simple validation to alter command対応中かも @drkemp187 が 106 日前に担当しました。 オープンenhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
github/gh-ost#1431 · コメント 4 件 ·
メンテナーはふだん 10 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 10 日以内に返信
-
Atomic cut-over always fails on MySQL 9.1+: information_schema.processlist errors out (3854) while another session runs a non-BMP utf8mb4 statement対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
github/gh-ost#1780 · コメント 1 件 ·
メンテナーはふだん 10 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
メンテナーはふだん 10 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
prime-radiant-inc/evener#6325 ·
メンテナーはふだん 1 日以内に返信
-
team:library-maintainers
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
padok-team/burrito#1208 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
bazel-contrib/rules_go#4784 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
betterleaks/betterleaks#484 ·
メンテナーはふだん 1 日以内に返信