{
  "id": "mongodb/change-stream-resume-token-invalid-namespace",
  "signature": "MongoServerError: change stream resume token invalid for namespace 'mydb.mycoll': token belongs to different database",
  "signature_zh": "MongoServerError：变更流恢复令牌对命名空间 'mydb.mycoll' 无效：令牌属于不同的数据库",
  "regex": "change stream resume token invalid for namespace.*token belongs to different",
  "domain": "mongodb",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "The resume token provided to open a change stream was generated from a different database or collection than the one being watched, causing a namespace mismatch.",
  "root_cause_type": "generic",
  "root_cause_zh": "提供的恢复令牌用于打开变更流，但该令牌来自与被监视的数据库或集合不同的命名空间，导致命名空间不匹配。",
  "versions": [],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Reusing a resume token from a different replica set or sharded cluster (e.g., from production in a test environment) still fails because the token is cluster-specific.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Manually editing the resume token's namespace field in the application code does not work because the server validates the token against internal metadata.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Open a new change stream without a resume token (e.g., db.collection.watch([], {startAtOperationTime: Timestamp(1, 1)})) to start from the earliest possible point, then capture a fresh token for future resumption.",
      "success_rate": 0.85,
      "how": "Open a new change stream without a resume token (e.g., db.collection.watch([], {startAtOperationTime: Timestamp(1, 1)})) to start from the earliest possible point, then capture a fresh token for future resumption.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the token is from a different namespace, construct a new change stream on the correct namespace using db.collection.watch() and ignore the old token. Example in Node.js: const changeStream = collection.watch(); changeStream.on('change', (change) => { console.log(change._id); });",
      "success_rate": 0.9,
      "how": "If the token is from a different namespace, construct a new change stream on the correct namespace using db.collection.watch() and ignore the old token. Example in Node.js: const changeStream = collection.watch(); changeStream.on('change', (change) => { console.log(change._id); });",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Open a new change stream without a resume token (e.g., db.collection.watch([], {startAtOperationTime: Timestamp(1, 1)})) to start from the earliest possible point, then capture a fresh token for future resumption.",
    "If the token is from a different namespace, construct a new change stream on the correct namespace using db.collection.watch() and ignore the old token. Example in Node.js: const changeStream = collection.watch(); changeStream.on('change', (change) => { console.log(change._id); });"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/changeStreams/#resume-a-change-stream",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.87,
  "resolvable": "true",
  "first_seen": "2023-09-28",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}