{"record":{"id":"63d132e7a3de20c9","repo":"risingwavelabs/risingwave","slug":"table-id-table-id-may-have-been-dropped","errorCode":null,"errorMessage":"table id {table_id} may have been dropped","messagePattern":"table id (.+?) may have been dropped","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/scheduler/snapshot.rs","lineNumber":181,"sourceCode":"\n/// A reference to a frontend-pinned snapshot.\npub type PinnedSnapshotRef = Arc<PinnedSnapshot>;\n\nimpl PinnedSnapshot {\n    fn batch_query_epoch(\n        &self,\n        read_storage_tables: &HashSet<TableId>,\n    ) -> Result<Epoch, SchedulerError> {\n        // use the min committed epoch of tables involved in the scan\n        let epoch = read_storage_tables\n            .iter()\n            .map(|table_id| {\n                self.value\n                    .state_table_info\n                    .info()\n                    .get(table_id)\n                    .map(|info| Epoch(info.committed_epoch))\n                    .ok_or_else(|| anyhow!(\"table id {table_id} may have been dropped\"))\n            })\n            .try_fold(None, |prev_min_committed_epoch, committed_epoch| {\n                committed_epoch.map(|committed_epoch| {\n                    if let Some(prev_min_committed_epoch) = prev_min_committed_epoch\n                        && prev_min_committed_epoch <= committed_epoch\n                    {\n                        Some(prev_min_committed_epoch)\n                    } else {\n                        Some(committed_epoch)\n                    }\n                })\n            })?\n            .unwrap_or_else(Epoch::now);\n        Ok(epoch)\n    }\n\n    pub fn version(&self) -> &FrontendHummockVersion {\n        &self.value","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/scheduler/snapshot.rs#L163-L199","documentation":"In snapshot batch query setup (`batch_query_epoch`, src/frontend/src/scheduler/snapshot.rs:181), each table id in the query is looked up in the snapshot's `state_table_info` to obtain its committed epoch. If a table id is missing from the mapping, the code assumes the table `may have been dropped` between query planning and snapshot epoch resolution, and returns this anyhow error (surfaced as `SchedulerError::Internal`).","triggerScenarios":"Running a batch query whose plan references a state table that is absent from the meta snapshot: the table (or its owning MV/index) was dropped concurrently after the query was planned.","commonSituations":"Race between `DROP TABLE`/`DROP MATERIALIZED VIEW` and a running SELECT against that object; stale cached plans referencing removed tables.","solutions":["Re-run the query; if the object was intentionally dropped it should now fail with a clear not-found error instead.","Verify the table/MV still exists (`SHOW MATERIALIZED VIEWS;` / `SHOW TABLES;`) and recreate it if it was dropped.","Avoid dropping a table while queries against it are in flight; coordinate DDL and query workloads.","If the table exists but the error persists, check meta consistency and re-create the object or restart the meta service."],"exampleFix":"// before: SELECT * FROM mv;  -- dropped concurrently\n// after\nCREATE MATERIALIZED VIEW IF NOT EXISTS mv AS SELECT ...;\nSELECT * FROM mv;","handlingStrategy":"retry","validationCode":"-- Check the object still exists before querying\nSELECT 1 FROM rw_catalog.rw_tables WHERE table_id = <id>;\nSELECT 1 FROM rw_catalog.rw_materialized_views WHERE name = 'mv';","typeGuard":null,"tryCatchPattern":"match scheduler_result {\n    Err(e) if e.to_string().contains(\"may have been dropped\") => {\n        // transient DDL race: re-plan and retry once\n        retry_query_once();\n    }\n    r => r?,\n}","preventionTips":["Avoid DROP TABLE/MV while queries against it run.","Wrap queries on volatile objects in retry logic.","Recreate objects before re-running dependent queries after DDL."],"tags":["scheduler","snapshot","epoch","dropped-table"],"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"}