Aurora retry logging: accurate reasons, correct levels, never throw - #90
Merged
Conversation
…tcher Log message/level fixes in withRetry: - Include the actual failure reason in every log line (previously the per-attempt retry WARN was a bare "Aurora query failed — retrying" with no indication of why). - Read that reason from the unwrapped SDK/driver cause rather than DrizzleQueryError's own message, which dumps the raw SQL and bound parameter values (e.g. a thread ID) — keeping that out of the log title while the full error (query text included) still reaches the log via the `error` context field. - Downgrade the per-attempt retry log to INFO when the failure is Aurora resuming from auto-pause: expected, self-resolving, and already flagged once by the existing "aurora.resume_detected" INFO log. Non-resume transient failures still log at WARN. Never-throw refactor: - withRetry() now returns Result<T, DbError> instead of throwing — every terminal failure comes back as an err(DbError) carrying the operation name and the attempt count it gave up at (new optional `operation`/`attempts` fields on DbError), so callers get full context without needing their own try/catch around a throw. - Every ThreadMatcher method now checks the Result directly instead of wrapping withRetry in try/catch and re-deriving a DbError from a caught exception. - processor.ts's tier-2 similarity search previously discarded ThreadMatcher.findMatch() errors with no logging at all; it now logs a WARN (matching the existing tier-1.5 pattern) before degrading to "no match".
Nothing outside withRetry acts on how many attempts it took; only the operation name is useful context for a caller. The attempt count stays in the per-attempt log lines, where it's actually meaningful.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
aurora.retryWARN log, which previously said only "Aurora query failed — retrying" with no indication of why. It now includes the actual failure reason.DrizzleQueryError's own.message, which dumps the raw SQL and bound parameter values (e.g. a thread ID) — that stays out of the log title/message while the full error (query text included) is still available via theerrorcontext field.aurora.resume_detectedINFO log. Non-resume transient failures still log at WARN.withRetry()insrc/database/thread-matcher.tsno longer throws — it returnsResult<T, DbError>. Every terminal failure comes back as anerr(DbError)carrying the operation name and the attempt count it gave up at (new optionaloperation/attemptsfields onDbErrorinsrc/errors.ts), so callers get full context without wrapping it in their own try/catch.ThreadMatchermethod now checks thatResultdirectly instead of wrappingwithRetryin try/catch and re-deriving aDbErrorfrom a caught exception.processor.ts's tier-2 similarity search previously discardedThreadMatcher.findMatch()errors with no logging at all; it now logs a WARN (matching the existing tier-1.5In-Reply-Topattern) before degrading to "no match".Test plan
npx tsc --noEmitpassesnpx eslint src/database/thread-matcher.ts src/errors.ts src/processor/processor.tspasses cleannpx vitest run— 2846/2846 passGenerated by Claude Code