{"record":{"id":"b4cfe14e420aec8f","repo":"t8y2/dbx","slug":"w-after-ds","errorCode":null,"errorMessage":"%w after %ds","messagePattern":"%w after (.+?)s","errorType":"exception","errorClass":"errXuguOperationTimeout","httpStatus":null,"severity":"error","filePath":"agents/drivers/xugu/main.go","lineNumber":4322,"sourceCode":"\tif s.activeTimer != nil {\n\t\ts.activeTimer.Stop()\n\t\ts.activeTimer = nil\n\t}\n\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.","sourceCodeStart":4304,"sourceCodeEnd":4340,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/xugu/main.go#L4304-L4340","documentation":"The clean timeout variant: the operation timed out after timeoutSecs but the waiter itself produced no additional error, so the driver returns a wrapped errXuguOperationTimeout ('xugu operation timed out') with only the duration. The %w wrapping lets callers match with errors.Is(err, errXuguOperationTimeout).","triggerScenarios":"A monitored operation's elapsed time exceeded timeoutSecs and the result channel/poll returned normally, indicating pure timeout without a secondary failure.","commonSituations":"Queries exceeding a deliberately short timeout; batch jobs hitting a fixed timeout budget; server under load causing slow but healthy operations.","solutions":["Increase timeoutSecs to a value appropriate for the statement's expected duration.","Profile and optimize the slow SQL (indexes, statistics, partitions).","Run long operations asynchronously or in the background instead of under a short wait.","Retry during off-peak windows if the timeout is load-related."],"exampleFix":"// before\nrows, err := q.Run(sql, 10) // times out after 10s on big scan\n\n// after\nrows, err := q.Run(sql, 120)","handlingStrategy":"retry","validationCode":"// ensure the timeout budget covers worst-case plan\nexplain, _ := db.Query(\"EXPLAIN \" + sql)\n// compare estimated rows against timeout heuristic before executing","typeGuard":null,"tryCatchPattern":"if errors.Is(err, errXuguOperationTimeout) {\n    return retryWithLargerTimeout(op, timeoutSecs*2)\n}","preventionTips":["Benchmark slow statements and set timeouts above p99 runtime.","Optimize queries with indexes/statistics rather than raising timeouts indefinitely.","Run known-long jobs outside interactive timeouts."],"tags":["database","timeout","xugu"],"backgroundTag":"operation-timeout","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}