{"record":{"id":"d7c25c660576990f","repo":"risingwavelabs/risingwave","slug":"failed-to-execute-time-travel-query","errorCode":null,"errorMessage":"Failed to execute time travel query","messagePattern":"Failed to execute time travel query","errorType":"error_code","errorClass":"BatchError","httpStatus":null,"severity":"error","filePath":"src/batch/src/error.rs","lineNumber":153,"sourceCode":"    ServingVnodeMappingNotFound(FragmentId),\n\n    #[error(\"Streaming vnode mapping has not been initialized\")]\n    StreamingVnodeMappingNotInitialized,\n\n    #[error(\"Streaming vnode mapping not found for fragment {0}\")]\n    StreamingVnodeMappingNotFound(FragmentId),\n\n    #[error(\"Not enough memory to run this query, batch memory limit is {0} bytes\")]\n    OutOfMemory(u64),\n\n    #[error(\"Failed to spill out to disk\")]\n    Spill(\n        #[from]\n        #[backtrace]\n        opendal::Error,\n    ),\n\n    #[error(\"Failed to execute time travel query\")]\n    TimeTravel(\n        #[source]\n        #[backtrace]\n        anyhow::Error,\n    ),\n}\n\n// Serialize/deserialize error.\nimpl From<memcomparable::Error> for BatchError {\n    fn from(m: memcomparable::Error) -> Self {\n        Self::Serde(m.into())\n    }\n}\nimpl From<ValueEncodingError> for BatchError {\n    fn from(e: ValueEncodingError) -> Self {\n        Self::Serde(e.into())\n    }\n}","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/batch/src/error.rs#L135-L171","documentation":"BatchError::TimeTravel wraps an anyhow::Error raised when executing a time travel query — a query against a historical snapshot of a table (time travel / historical version reads). The batch frontend/engine failed while resolving or reading the historical version, and the underlying root cause is preserved in the source.","triggerScenarios":"Running `SELECT ... FROM table FOR SYSTEM_TIME AS OF <timestamp/version>` where the requested snapshot is outside the retention window, the underlying Hummock version/SST no longer exists, or the internal time-travel read fails.","commonSituations":"Querying a timestamp older than the configured retention period, time travel queried against a table without historical data support, cluster upgraded/collections GC'd so old snapshots are gone.","solutions":["Query a more recent timestamp within the retention window.","Increase the retention/history configuration so older snapshots are kept.","Verify the target table supports time travel and the timestamp format/semantics used.","Inspect the wrapped anyhow source (chain) for the underlying Hummock/storage error and fix that cause."],"exampleFix":"-- before\nSELECT * FROM t FOR SYSTEM_TIME AS OF '2020-01-01 00:00:00';  -- snapshot already GC'd\n\n-- after\nSELECT * FROM t FOR SYSTEM_TIME AS OF now() - INTERVAL '10 minutes';  -- within retention","handlingStrategy":"try-catch","validationCode":"// Before running, check the AS OF timestamp is within retention:\n// if ts < now - retention_window { use a newer ts or raise retention config }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(BatchError::TimeTravel(src)) => {\n        // inspect src (anyhow chain) for retention/GC errors and pick a newer snapshot\n    }\n    other => other?,\n}","preventionTips":["Keep query timestamps within the configured snapshot retention window.","Increase retention/history settings for workloads needing older snapshots.","Verify the table supports time travel before writing queries against history.","Log the full anyhow error chain to identify the underlying storage cause."],"tags":["time-travel","batch","snapshot","storage"],"backgroundTag":"database-query-failed","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}