Repository navigation
fix(moerr): keep cancellation identity through ConvertGoError and RPC - #29316
Conversation
…ellation When one shard of a parallel parquet LOAD fails, it cancels its siblings, and the scheduler reports the failing shard's error: a sibling's error that is a cancellation from that pipeline is resolved to the cancel cause (normalizeScopeRunError / preferPrimaryScopeResult). That only works if the cancellation is recognisable with errors.Is. The parquet reader passed every library error through moerr.ConvertGoError, which formats it into an internal error. A sibling canceled mid-read reported parquet-go's "reading magic footer of parquet file: context canceled" as "internal error: convert go error to mo error ...", no longer a cancellation, so whichever shard result was collected first won. load_data_parquet's pq_file_fanout_rollback case failed intermittently in multi-CN CI this way, reporting that instead of "invalid input: column name not found". The parquet reader now converts library errors with convertReaderError, which returns a cancellation or deadline unchanged and otherwise defers to moerr.ConvertGoError. ConvertGoError itself is unchanged: the RPC error encoders rely on it always returning *moerr.Error. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Replace the parquet-only convertReaderError with a central fix. moerr.ConvertGoError formatted every Go error into an internal error, so a context cancellation or deadline (often wrapped by a library, e.g. parquet-go's "reading magic footer of parquet file: context canceled") stopped matching errors.Is(err, context.Canceled/DeadlineExceeded). The scope scheduler relies on that to report a failing shard's error instead of a canceled sibling's (matrixorigin#29315), and the frontend, CDC and RPC clients check it too. The four RPC error encoders also flatten through ConvertGoError, so a remote cancellation arrived as an internal error. ConvertGoError now converts a context error to one of two new codes, ErrContextCanceled (MySQL ER_QUERY_INTERRUPTED) and ErrDeadlineExceeded, keeping the original text as the message; a deadline joined with a cancellation keeps the deadline. moerr.Error gains an Is method that matches only those two codes to context.Canceled and context.DeadlineExceeded, so errors.Is behaves after conversion, and after an RPC round trip since the code is serialized, as it did before; errors built directly (a killed query, a statement timeout) are unaffected. The result is still a *moerr.Error, as the RPC encoders require. Older nodes decode the new codes unchanged, as unmarshalling does not validate codes. Tests: conversion, MySQL code, message, marshal round trip and the unaffected codes (moerr); a locally converted and an RPC-decoded reader cancellation resolve to the failing shard's error (TestPreferPrimaryScopeResult); a parquet open canceled by a sibling reports a cancellation (external). All fail without the change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Related: #29290 (unpublished S3 cleanup ownership) depends on this PR on its failure path — see review #29290 (review). That PR returns 🤖 Generated with Claude Code |
Merge Queue Status
This pull request spent 28 minutes 18 seconds in the queue, with no time running CI. ReasonHintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #29315
What this PR does / why we need it:
load_data/load_data_parquet.sqlfails intermittently in multi-CN CI atpq_file_fanout_rollback. It failed on #29303, whose change is unrelated.Root cause
normalizeScopeRunError/preferPrimaryScopeResult, viaerrors.Is).moerr.ConvertGoErrorformatted every Go error into an internal error. So a context cancellation or deadline, often wrapped by a library, stopped matchingerrors.Is(err, context.Canceled/DeadlineExceeded), and whichever shard's result was collected first won.It's not only the parquet reader:
compile.go) flattens the same way.pkg/pb/{pipeline,shard,lock,query}) go throughConvertGoErrortoo, so a remote scope's cancellation reached the coordinator as an internal error.errors.Isagainst the context sentinels, including the frontend, CDC and RPC clients.Fix, in
moerrConvertGoErrorconverts a context error, wrapped or not, to one of two new codes. The message is the original text.ErrContextCanceled(20109), sent to clients as MySQLER_QUERY_INTERRUPTED.ErrDeadlineExceeded(20110). A deadline joined with a cancellation keeps the deadline.Error.Is: it matches only those two codes tocontext.Canceled/context.DeadlineExceeded.errors.Isthen behaves after conversion as it did before, and also after an RPC round trip, because the code is what's serialized.ErrQueryInterrupted) or a statement timeout (ErrQueryTimeout), don't gain newerrors.Ismatches.*moerr.Error, as the RPC encoders require. Returning raw context errors panicked those paths.This replaces the parquet-only
convertReaderErrorfrom the first commit of this PR. The parquet reader usesmoerr.ConvertGoErroragain.Tests
Each of these fails without the change:
TestConvertGoErrorKeepsContextIdentity: the mapping, MySQL codes, kept message, marshal/unmarshal round trip, deadline-over-cancellation for joined errors, and that directly builtErrQueryInterrupted/ErrQueryTimeout/ internal errors are unaffected.TestPreferPrimaryScopeResult: a sibling's parquet cancellation, both converted locally and decoded frompipeline.EncodedMessageError, resolves to the failing shard's error.TestParquetOpenFileCanceledBySibling: opening a real parquet file with a context canceled by a sibling reportsErrContextCanceled, which matchescontext.Canceled.Other checks:
go test:common/moerr,sql/compile,sql/colexec/external,pb/...,cdc,txn/service,util/export/etl,sql/plan/function/ctl,frontend,lockservice,shardserviceandqueryserviceall pass.make static-check: 0 issues.The CI race itself doesn't reproduce locally (60/60 single-node runs gave the expected error), so the tests cover the mechanism deterministically.
Not covered
Code that flattens errors itself, e.g.
moerr.NewInternalErrorf("...%v", err)orerr.Error(), still loses the identity. Those sites need routing throughConvertGoErrorwherever a cancellation can reach them; that's a separate follow-up.🤖 Generated with Claude Code