{"record":{"id":"908b06fa1b38b9a2","repo":"t8y2/dbx","slug":"w-v","errorCode":null,"errorMessage":"%w: %v","messagePattern":"%w: %v","errorType":"exception","errorClass":"errXuguOperationCanceled","httpStatus":null,"severity":"error","filePath":"agents/drivers/xugu/main.go","lineNumber":4326,"sourceCode":"\ttimedOut := s.activeTimedOut\n\tcanceled := s.activeCanceled\n\ts.activeTimedOut = false\n\ts.activeCanceled = false\n\ts.activeCancelMu.Unlock()\n\tcancel()\n\treturn xuguOperationResultError(timedOut, canceled, timeoutSecs, operationErr)\n}\n\nfunc xuguOperationResultError(timedOut, canceled bool, timeoutSecs int, operationErr error) error {\n\tif timedOut {\n\t\tif operationErr != nil {\n\t\t\treturn fmt.Errorf(\"%w after %ds: %v\", errXuguOperationTimeout, timeoutSecs, operationErr)\n\t\t}\n\t\treturn fmt.Errorf(\"%w after %ds\", errXuguOperationTimeout, timeoutSecs)\n\t}\n\tif canceled {\n\t\tif operationErr != nil {\n\t\t\treturn fmt.Errorf(\"%w: %v\", errXuguOperationCanceled, operationErr)\n\t\t}\n\t\treturn errXuguOperationCanceled\n\t}\n\treturn operationErr\n}\n\nfunc (s *server) cancelActiveQuery() {\n\ts.activeCancelMu.Lock()\n\tcancels := make([]context.CancelFunc, 0, len(s.activeRows)+1)\n\tif s.activeCancel != nil {\n\t\tif !s.activeTimedOut {\n\t\t\ts.activeCanceled = true\n\t\t\t// Explicit cancellation won the race. Disable the watchdog so a\n\t\t\t// slow driver return cannot relabel this operation as a timeout.\n\t\t\tif s.activeTimer != nil {\n\t\t\t\ts.activeTimer.Stop()\n\t\t\t\ts.activeTimer = nil\n\t\t\t}","sourceCodeStart":4308,"sourceCodeEnd":4344,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/xugu/main.go#L4308-L4344","documentation":"When the operation was canceled (context canceled / client abort) and the waiter also captured an error, the driver returns errXuguOperationCanceled ('xugu operation canceled' family) wrapped with the underlying error via %w. Callers can detect cancellation with errors.Is even though the message includes the cause.","triggerScenarios":"The caller's context was canceled or the client closed/canceled the request while the operation was still running, and operationErr carries the driver-level cancellation error.","commonSituations":"HTTP request contexts canceled by the client disconnecting; ctx.WithTimeout on the application side firing first; shutting down a service mid-query; user-initiated aborts in tools built on the driver.","solutions":["Inspect the %v cause to identify which context or client canceled the work.","Ensure application contexts have adequate deadlines before dispatching long operations.","Avoid canceling clients/connections mid-operation; use server-side query limits instead.","Detect deliberate cancellation with errors.Is(err, errXuguOperationCanceled) and handle it as a non-fatal path."],"exampleFix":"// before\nctx, cancel := context.WithTimeout(ctx, 5*time.Second) // too short, cancels mid-query\n\n// after\nctx, cancel := context.WithTimeout(ctx, 120*time.Second)","handlingStrategy":"type-guard","validationCode":"select {\ncase <-ctx.Done():\n    return fmt.Errorf(\"aborted before dispatch: %w\", ctx.Err())\ndefault:\n    // safe to start the operation\n}","typeGuard":"func IsCanceledErr(err error) bool { return errors.Is(err, errXuguOperationCanceled) || errors.Is(err, context.Canceled) }","tryCatchPattern":"if IsCanceledErr(err) {\n    log.Info(\"operation canceled by caller\")\n    return nil // expected during shutdown\n}","preventionTips":["Give operations contexts with realistic deadlines before dispatch.","Distinguish deliberate cancellation from failure in handlers.","Drain in-flight operations during graceful shutdown instead of hard-canceling."],"tags":["database","canceled","context","xugu"],"backgroundTag":"operation-canceled","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}