From 9b88c52458c03d6163954b73dbd46a30aedf045e Mon Sep 17 00:00:00 2001 From: Jakub Pliszka Date: Fri, 15 May 2026 16:07:15 +0100 Subject: [PATCH] Handle context cancellation in consumeRowCopyComplete to prevent deadlocks --- go/logic/migrator.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/go/logic/migrator.go b/go/logic/migrator.go index aaacbdd2e..052ff9744 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -234,10 +234,14 @@ func (mgtr *Migrator) retryOperationWithExponentialBackoff(operation func() erro // consumeRowCopyComplete blocks on the rowCopyComplete channel once, and then // consumes and drops any further incoming events that may be left hanging. func (mgtr *Migrator) consumeRowCopyComplete() { - if err := <-mgtr.rowCopyComplete; err != nil { - // Abort synchronously to ensure checkAbort() sees the error immediately - mgtr.abort(err) - // Don't mark row copy as complete if there was an error + select { + case err := <-mgtr.rowCopyComplete: + if err != nil { + mgtr.abort(err) + return + } + case <-mgtr.migrationContext.GetContext().Done(): + // Abort cancelled the context return } atomic.StoreInt64(&mgtr.rowCopyCompleteFlag, 1)