{"record":{"id":"edb86ef4c5cc921f","repo":"risingwavelabs/risingwave","slug":"cannot-find-the-snapshot-id-in-the-iceberg-table","errorCode":null,"errorMessage":"Cannot find the snapshot id in the iceberg table.","messagePattern":"Cannot find the snapshot id in the iceberg table\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/source/iceberg/mod.rs","lineNumber":313,"sourceCode":"    pub schema: std::sync::Arc<iceberg::spec::Schema>,\n}\n\nimpl IcebergSplitEnumerator {\n    pub fn get_snapshot_id(\n        table: &Table,\n        time_travel_info: Option<IcebergTimeTravelInfo>,\n    ) -> ConnectorResult<Option<i64>> {\n        Self::get_snapshot_id_from_metadata(table.metadata(), time_travel_info)\n    }\n\n    fn get_snapshot_id_from_metadata(\n        metadata: &TableMetadata,\n        time_travel_info: Option<IcebergTimeTravelInfo>,\n    ) -> ConnectorResult<Option<i64>> {\n        let snapshot_id = match time_travel_info {\n            Some(IcebergTimeTravelInfo::Version(version)) => {\n                let Some(snapshot) = metadata.snapshot_by_id(version) else {\n                    bail!(\"Cannot find the snapshot id in the iceberg table.\");\n                };\n                Some(snapshot.snapshot_id())\n            }\n            Some(IcebergTimeTravelInfo::TimestampMs(timestamp)) => {\n                let snapshot_log = metadata\n                    .history()\n                    .iter()\n                    .rev()\n                    .find(|snapshot_log| snapshot_log.timestamp_ms() <= timestamp);\n                match snapshot_log {\n                    Some(snapshot_log) => Some(snapshot_log.snapshot_id),\n                    None => {\n                        // convert unix time to human-readable time\n                        let time = chrono::DateTime::from_timestamp_millis(timestamp);\n                        if let Some(time) = time {\n                            tracing::warn!(\"Cannot find a snapshot older than {}\", time);\n                        } else {\n                            tracing::warn!(\"Cannot find a snapshot\");","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/source/iceberg/mod.rs#L295-L331","documentation":"When time travel to a specific snapshot version is requested for an Iceberg source, `get_snapshot_id_from_metadata` looks up the requested snapshot id in the table metadata via `snapshot_by_id`. If the metadata contains no snapshot with that id, the function bails with this error. It means the requested snapshot does not exist (or no longer exists) in the current table metadata.","triggerScenarios":"Querying a `CREATE SOURCE ... WITH (time travel)`/scan with `IcebergTimeTravelInfo::Version(v)` where `v` is not a snapshot id present in `TableMetadata::snapshot_by_id` — e.g. a stale, typo'd, or expired (retention-expired) snapshot id.","commonSituations":"Using a snapshot id captured from an older table state that has since been rewritten; referencing a snapshot removed by expire_snapshots; typo in the version configured in source properties; pointing a source at a different table than the snapshot belongs to.","solutions":["List current table snapshots (iceberg metadata) and use an existing snapshot id.","Re-create or update the source with a valid/current snapshot version.","If targeting a point in time, switch to timestamp-based time travel (`IcebergTimeTravelInfo::TimestampMs`) instead of a fixed snapshot id.","Check that expire-snapshot jobs have not removed the snapshot; increase retention if needed."],"exampleFix":"// before\n{\"iceberg.time_travel.version\": \"87241518739178\"}\n// after: use a snapshot id present in current metadata\n{\"iceberg.time_travel.version\": \"<id from SELECT * FROM table.snapshots>\"}","handlingStrategy":"validation","validationCode":"let exists = metadata.snapshot_by_id(requested_version).is_some();\nif !exists {\n    // pick a valid snapshot from metadata.snapshots() or fall back to latest\n}","typeGuard":"fn snapshot_exists(m: &TableMetadata, id: i64) -> bool { m.snapshot_by_id(id).is_some() }","tryCatchPattern":"match get_snapshot_id_from_metadata(&metadata, travel_info) {\n    Ok(id) => id,\n    Err(e) if e.to_string().contains(\"Cannot find the snapshot id\") => {\n        // fall back to current snapshot or refresh the configured version\n        None\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Resolve snapshot ids from the live table metadata at query time, not hardcoded values","Beware expire_snapshots removing referenced ids","Prefer timestamp-based time travel for point-in-time reads"],"tags":["rust","iceberg","time-travel","snapshot"],"backgroundTag":"resource-not-found","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"}