{
  "id": "mongodb/change-stream-resume-token-wiredtiger-stale",
  "signature": "MongoServerError: ChangeStream error: resume token from WiredTiger is stale: token timestamp 1234567890 is older than oldest timestamp 1234567895",
  "signature_zh": "MongoServerError：更改流错误：来自WiredTiger的恢复令牌已过期：令牌时间戳1234567890早于最旧时间戳1234567895",
  "regex": "ChangeStream error: resume token from WiredTiger is stale: token timestamp \\d+ is older than oldest timestamp \\d+",
  "domain": "mongodb",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The resume token timestamp has been pruned from WiredTiger's history because the storage engine's oldest timestamp advanced past it due to checkpoint or replication pressure.",
  "root_cause_type": "generic",
  "root_cause_zh": "由于检查点或复制压力导致存储引擎的最旧时间戳超过了恢复令牌时间戳，该令牌已从WiredTiger的历史记录中被修剪。",
  "versions": [
    {
      "version": "mongodb 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The token is already pruned from the oplog and WiredTiger; retrying with the same token will result in the same error.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Checkpoint frequency does not directly control timestamp pruning; the oldest timestamp is managed by replication and read concern settings.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This is not configurable and would break point-in-time read operations; the error is a symptom of a broader retention issue.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the oplog size to retain more history: `db.adminCommand({ replSetResizeOplog: 1, size: 40960 })` (40GB) and use `db.adminCommand({ setParameter: 1, minSnapshotHistoryWindowInSeconds: 3600 })` to keep WiredTiger snapshots for 1 hour.",
      "success_rate": 0.85,
      "how": "Increase the oplog size to retain more history: `db.adminCommand({ replSetResizeOplog: 1, size: 40960 })` (40GB) and use `db.adminCommand({ setParameter: 1, minSnapshotHistoryWindowInSeconds: 3600 })` to keep WiredTiger snapshots for 1 hour.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement fallback logic in the application: on this error, start a new change stream from the current time using `db.collection.watch([], { startAfter: resumeToken })` or `{ startAtOperationTime: Timestamp(...) }` and reprocess recent events.",
      "success_rate": 0.9,
      "how": "Implement fallback logic in the application: on this error, start a new change stream from the current time using `db.collection.watch([], { startAfter: resumeToken })` or `{ startAtOperationTime: Timestamp(...) }` and reprocess recent events.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce the resume token interval by polling change streams more frequently (e.g., every 5 seconds instead of 30 seconds) to keep tokens within the retention window.",
      "success_rate": 0.7,
      "how": "Reduce the resume token interval by polling change streams more frequently (e.g., every 5 seconds instead of 30 seconds) to keep tokens within the retention window.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase the oplog size to retain more history: `db.adminCommand({ replSetResizeOplog: 1, size: 40960 })` (40GB) and use `db.adminCommand({ setParameter: 1, minSnapshotHistoryWindowInSeconds: 3600 })` to keep WiredTiger snapshots for 1 hour.",
    "Implement fallback logic in the application: on this error, start a new change stream from the current time using `db.collection.watch([], { startAfter: resumeToken })` or `{ startAtOperationTime: Timestamp(...) }` and reprocess recent events.",
    "Reduce the resume token interval by polling change streams more frequently (e.g., every 5 seconds instead of 30 seconds) to keep tokens within the retention window."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/changeStreams/#resume-tokens",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2024-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}