{"record":{"id":"c96c4ebad13bd4e8","repo":"influxdata/influxdb","slug":"the-operation-was-cancelled-0","errorCode":null,"errorMessage":"The operation was cancelled: {0}","messagePattern":"The operation was cancelled: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"core/influxdb_iox_client/src/client/error.rs","lineNumber":66,"sourceCode":"}\n\nimpl ServerErrorDetails for NotFound {\n    fn try_decode(status: &Status) -> Option<Self> {\n        generated_types::google::decode_not_found(status).next()\n    }\n}\n\nimpl ServerErrorDetails for PreconditionViolation {\n    fn try_decode(status: &Status) -> Option<Self> {\n        generated_types::google::decode_precondition_violation(status).next()\n    }\n}\n\n/// The errors returned by this client\n#[derive(Error, Debug)]\n#[expect(missing_docs)]\npub enum Error {\n    #[error(\"The operation was cancelled: {0}\")]\n    Cancelled(ServerError<()>),\n\n    #[error(\"Unknown server error: {0}\")]\n    Unknown(ServerError<()>),\n\n    #[error(\"Client specified an invalid argument: {0}\")]\n    InvalidArgument(Box<ServerError<FieldViolation>>),\n\n    #[error(\"Deadline expired before operation could complete: {0}\")]\n    DeadlineExceeded(ServerError<()>),\n\n    #[error(\"{0}\")]\n    NotFound(Box<ServerError<NotFound>>),\n\n    #[error(\"Some entity that we attempted to create already exists: {0}\")]\n    AlreadyExists(Box<ServerError<AlreadyExists>>),\n\n    #[error(\"The caller does not have permission to execute the specified operation: {0}\")]","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_iox_client/src/client/error.rs#L48-L84","documentation":"`Error::Cancelled` is one of the typed client errors mapping a gRPC `CANCELLED` status: \"The operation was cancelled: {0}\". It is returned when the operation was cancelled, typically by the client itself or by the server shutting down / shedding work, with the wrapped `ServerError` carrying the server's message.","triggerScenarios":"A gRPC call through the IOx client returning status `CANCELLED` — e.g. the caller dropped/cancelled the future mid-request, a deadline or shutdown cancelled the call, or the server explicitly cancelled the operation.","commonSituations":"Application shutdown or tokio runtime teardown while requests are in flight; timeouts implemented via `tokio::time::timeout` dropping futures; server restarts or overload causing work cancellation; users aborting long-running queries.","solutions":["Retry the operation if the cancellation was transient (e.g. server restart); use idempotent requests and bounded retries with backoff.","Check whether your own code (timeout wrappers, `abort()`, dropping futures) cancelled the call and adjust.","Verify server health/uptime; during shutdowns wait or reconnect to a healthy node.","Match on `Error::Cancelled` explicitly to distinguish cancellation from other failures and choose retry vs abort accordingly."],"exampleFix":"// before\nlet res = client.query(req).await?; // aborted on shutdown\n// after\nlet res = match client.query(req).await {\n    Err(Error::Cancelled(se)) if is_retryable(&se) => {\n        tokio::time::sleep(Duration::from_millis(200)).await;\n        client.query(req).await?\n    }\n    other => other?,\n};","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match result {\n    Err(Error::Cancelled(_)) => retry_with_backoff(op, max_retries = 3),\n    other => other,\n}","preventionTips":["Avoid wrapping client calls in abort-prone timeout/selection constructs without retry","Drain in-flight requests gracefully during shutdown before dropping the runtime","Use bounded retries with exponential backoff for cancelled idempotent operations"],"tags":["rust","grpc","cancellation","client"],"backgroundTag":"request-timeout","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}