{"record":{"id":"e08c0b429d40a0ce","repo":"risingwavelabs/risingwave","slug":"cannot-find-subscription-with-id","errorCode":null,"errorMessage":"cannot find subscription with id {}","messagePattern":"cannot find subscription with id (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/src/controller/catalog/get_op.rs","lineNumber":342,"sourceCode":"            })\n            .collect())\n    }\n\n    pub async fn get_subscription_by_id(\n        &self,\n        subscription_id: SubscriptionId,\n    ) -> MetaResult<PbSubscription> {\n        let inner = self.inner.read().await;\n        let subscription_objs = Subscription::find()\n            .find_also_related(Object)\n            .filter(subscription::Column::SubscriptionId.eq(subscription_id))\n            .all(&inner.db)\n            .await?;\n        let subscription: PbSubscription = subscription_objs\n            .into_iter()\n            .map(|(subscription, obj)| ObjectModel(subscription, obj.unwrap(), None).into())\n            .find_or_first(|_| true)\n            .ok_or_else(|| anyhow!(\"cannot find subscription with id {}\", subscription_id))?;\n\n        Ok(subscription)\n    }\n\n    pub async fn get_mv_depended_subscriptions(\n        &self,\n        database_id: Option<DatabaseId>,\n    ) -> MetaResult<HashMap<TableId, HashMap<SubscriptionId, u64>>> {\n        let inner = self.inner.read().await;\n        let select = Subscription::find()\n            .select_only()\n            .select_column(subscription::Column::SubscriptionId)\n            .select_column(subscription::Column::DependentTableId)\n            .select_column(subscription::Column::RetentionSeconds);\n        let select = if let Some(database_id) = database_id {\n            select\n                .join(JoinType::InnerJoin, subscription::Relation::Object.def())\n                .filter(object::Column::DatabaseId.eq(database_id))","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/meta/src/controller/catalog/get_op.rs#L324-L360","documentation":"get_subscription_by_id looks up subscription catalog objects by id, maps them to PbSubscription models, and uses find_or_first(|_| true) to select the match. When the filtered iterator is empty (no subscription row/object exists for the given id), the ok_or_else on the resulting Option produces this anyhow error. It simply means no subscription with the requested id exists in the catalog.","triggerScenarios":"Calling get_subscription_by_id (e.g. via SHOW/META internal RPC) with a subscription_id that does not exist, or one that was already dropped in another session/transaction.","commonSituations":"Consumers holding stale subscription ids after the subscription was dropped; racing DDL where a subscription is removed while a client queries it; typos or id reuse assumptions in tooling.","solutions":["Verify the subscription id via the catalog (SHOW SUBSCRIPTIONS) before fetching by id.","Handle the not-found case: recreate the subscription if it was dropped.","Use the subscription name lookup instead of a cached id."],"exampleFix":"// before\nlet sub = controller.get_subscription_by_id(stale_id).await?;\n// after\nmatch controller.get_subscription_by_id(id).await {\n    Ok(sub) => sub,\n    Err(e) if e.to_string().contains(\"cannot find subscription\") => recreate_subscription(),\n    Err(e) => return Err(e),\n}","handlingStrategy":"try-catch","validationCode":"// Rust\nasync fn subscription_exists(controller: &CatalogController, id: u32) -> bool {\n    controller.list_subscriptions().await.map(|subs| subs.iter().any(|s| s.id == id)).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match controller.get_subscription_by_id(id).await {\n    Ok(sub) => sub,\n    Err(e) if e.to_string().contains(\"cannot find subscription with id\") => {\n        // treat as RecordNotFound: refresh catalog or recreate\n        refresh_and_recreate(id)\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Resolve subscriptions by name each time instead of caching ids.","Re-fetch the catalog after DDL that may drop subscriptions.","Handle RecordNotFound semantics for shared objects that others may drop concurrently."],"tags":["meta","subscription","not-found","catalog"],"backgroundTag":"entity-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"}