{"record":{"id":"1525eba3481d6eb5","repo":"tikv/tikv","slug":"error-1525eb","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coprocessor/endpoint.rs","lineNumber":1284,"sourceCode":"            && !pb_ctx.get_stale_read()\n            && !pb_ctx.get_replica_read()\n        {\n            // Some scenes are not supported before an effective argument, including:\n            // - stale-read & replica-read, TODO: support it later\n            // - non-SI isolation level, TODO: support it later\n            return Some(Self {\n                store_id,\n                req_ctx,\n                concurrency_manager,\n                _phantom: PhantomData,\n            });\n        }\n        None\n    }\n\n    #[inline]\n    fn err<S: Display>(s: S) -> StorageError {\n        StorageError::from(anyhow!(\"{}\", s))\n    }\n}\n\n#[async_trait]\nimpl<E: Engine> RegionStorageAccessor for ExtraSnapStoreAccessor<E> {\n    type Storage = SnapshotStore<E::IMSnap>;\n\n    /// find the region by the specified key.\n    /// The argument `key` should be the comparable format, you should use\n    /// `Key::from_raw` encode the raw key.\n    async fn find_region_by_key(&self, key: &[u8]) -> StorageResult<FindRegionResult> {\n        let key_in_vec = key.to_vec();\n        let (tx, rx) = oneshot::channel();\n        unsafe {\n            with_tls_engine(|engine: &mut E| -> StorageResult<()> {\n                engine\n                    .seek_region(\n                        key,","sourceCodeStart":1266,"sourceCodeEnd":1302,"githubUrl":"https://github.com/tikv/tikv/blob/78aedc1c81ef3f7d8bacc6e9d09f56460f134937/src/coprocessor/endpoint.rs#L1266-L1302","documentation":"The private helper `fn err<S: Display>(s: S) -> StorageError` in endpoint.rs builds a `StorageError` from an arbitrary displayable value via `anyhow!(\"{}\", s)`. It is the endpoint module's convenience constructor for ad-hoc storage errors with a formatted message; the message itself is whatever string the caller formats.","triggerScenarios":"Any call site inside the coprocessor Endpoint that invokes `err(...)` (or formats a message the same way) to convert a failure description into a `StorageError`, e.g. wrapping snapshot accessor or region lookup failures with a Display'd reason.","commonSituations":"Region snapshot creation failures, missing snapshots in the endpoint's extra-snapshot accessor (`ExtraSnapStoreAccessor`), or any code path needing a quick anyhow-backed StorageError from a Display value such as a region ID or key range.","solutions":["Read the formatted message in the error to determine which endpoint step failed.","Verify snapshot availability / region epoch freshness at the caller that produced the Display'd reason.","Retry the coprocessor request after the region cache refreshes if the cause was an epoch mismatch.","If the message is a transient storage issue, check RocksDB/raftstore health."],"exampleFix":"// before\nlet se = err(format!(\"no snapshot for region {}\", region_id));\n// after\nlet se = err(format!(\"no snapshot for region {}, epoch {:?}; check region cache\", region_id, epoch));","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn storage_err_message(e: &tidb_query_common::error::Error) -> String {\n    match e {\n        tidb_query_common::error::Error::StorageError(se) => se.to_string(),\n        other => other.to_string(),\n    }\n}","tryCatchPattern":"match endpoint_result {\n    Err(e) if e.to_string().contains(\"no snapshot\") => {\n        // snapshot gone: refresh region/snapshot and retry\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Keep snapshots alive while the endpoint may still use them (hold the Arc).","Include region id/epoch in the formatted message to speed diagnosis.","Refresh region cache after any epoch/leadership error before retrying."],"tags":["coprocessor","storage-error","snapshot","rust"],"backgroundTag":"coprocessor-storage-error-unclassified","analyzedSha":"78aedc1c81ef3f7d8bacc6e9d09f56460f134937","analyzedAt":"2026-09-03T23:31:32.398Z","contentChangedAt":"2026-09-03T23:31:32.398Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}