{
  "id": "mongodb/change-stream-namespace-not-found",
  "signature": "MongoServerError: change stream namespace not found",
  "signature_zh": "MongoServerError：变更流命名空间未找到",
  "regex": "MongoServerError:\\s*change stream namespace not found",
  "domain": "mongodb",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The collection or database specified in the change stream pipeline does not exist or was dropped during the stream's lifetime.",
  "root_cause_type": "generic",
  "root_cause_zh": "变更流管道中指定的集合或数据库不存在，或在流生命周期内被删除。",
  "versions": [
    {
      "version": "mongodb 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb 5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The collection still doesn't exist, so the error persists.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Batch size does not affect namespace validity; the root cause is missing collection.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Verify the collection exists before opening the change stream: db.collection('myColl').exists() then create if missing.",
      "success_rate": 0.85,
      "how": "Verify the collection exists before opening the change stream: db.collection('myColl').exists() then create if missing.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a try-catch block to recreate the change stream when this error occurs: try { cursor = collection.watch(); } catch (e) { if (e.code === 166) { db.createCollection('myColl'); } }",
      "success_rate": 0.75,
      "how": "Use a try-catch block to recreate the change stream when this error occurs: try { cursor = collection.watch(); } catch (e) { if (e.code === 166) { db.createCollection('myColl'); } }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在打开变更流前验证集合是否存在：db.collection('myColl').exists()，如果不存在则创建。",
    "使用try-catch块在出现此错误时重新创建变更流：try { cursor = collection.watch(); } catch (e) { if (e.code === 166) { db.createCollection('myColl'); } }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/changeStreams/#change-streams-and-collections",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-08-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}