Commit a524303
Handle context cancellation while waiting for ghost table migration
Migrate() blocks on an unbuffered receive from ghostTableMigrated while
waiting for the ghost table to be created. The only sender is
onChangelogStateEvent(), which publishes via base.SendWithContext().
If the migration aborts during this window, abort() cancels the
migration context, so SendWithContext() takes its ctx.Done() branch and
returns without ever sending. Nothing else writes to the channel, so
Migrate() blocks forever: it never returns, its deferred teardown()
never runs, finishedMigrating is never set, and the status and throttler
tickers -- which exit on finishedMigrating rather than on the context --
keep looping. The process stays alive indefinitely, logging a frozen
status line, until it is killed externally.
Extract the wait into waitForGhostTableMigrated() and select on the
migration context alongside the channel, returning checkAbort() so the
original abort error is surfaced rather than a bare context error. The
extraction mirrors consumeRowCopyComplete() and makes the behaviour
testable without a database.
This is the same deadlock, and the same fix, as #1677 applied to
consumeRowCopyComplete; ghostTableMigrated is its remaining sibling.
TestAbort_DuringGhostTableWait follows the existing TestAbort_* pattern
and fails (blocking until its timeout) without this change.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 2ed192c commit a524303
2 files changed
Lines changed: 76 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
270 | 286 | | |
271 | 287 | | |
272 | 288 | | |
| |||
554 | 570 | | |
555 | 571 | | |
556 | 572 | | |
557 | | - | |
558 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
559 | 576 | | |
560 | 577 | | |
561 | 578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1566 | 1566 | | |
1567 | 1567 | | |
1568 | 1568 | | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
1569 | 1626 | | |
1570 | 1627 | | |
1571 | 1628 | | |
| |||
0 commit comments