{
  "id": "mongodb/transaction-too-old-for-snapshot",
  "signature": "MongoServerError: TransactionTooOldForSnapshot: Read timestamp is older than the oldest timestamp in the storage engine's snapshot history",
  "signature_zh": "MongoServerError: 事务对于快照太旧：读取时间戳早于存储引擎快照历史中的最旧时间戳",
  "regex": "TransactionTooOldForSnapshot: Read timestamp is older than the oldest timestamp",
  "domain": "mongodb",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "A multi-document transaction is using a read timestamp that has been pruned from the WiredTiger storage engine's snapshot history, typically due to long-running transactions or insufficient snapshot retention.",
  "root_cause_type": "generic",
  "root_cause_zh": "多文档事务使用的读取时间戳已从 WiredTiger 存储引擎的快照历史中清除，通常是由于长时间运行的事务或快照保留不足。",
  "versions": [
    {
      "version": "mongodb-4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-4.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-4.4",
      "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"
    },
    {
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This does not affect snapshot retention; the issue is the storage engine pruning old snapshots, not the transaction timing out.",
      "fail_rate": 0.2,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Restarting resets the snapshot history but does not prevent pruning; the error will recur if the same pattern occurs.",
      "fail_rate": 0.1,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changing read concern may affect transaction isolation guarantees and does not address the root cause of long-running operations.",
      "fail_rate": 0.15,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Reduce the duration of transactions by committing them faster. Break large transactions into smaller batches. Example: instead of one transaction updating 10,000 documents, use 100 transactions of 100 documents each.",
      "success_rate": 0.9,
      "how": "Reduce the duration of transactions by committing them faster. Break large transactions into smaller batches. Example: instead of one transaction updating 10,000 documents, use 100 transactions of 100 documents each.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase the WiredTiger snapshot retention period by adjusting the `storage.wiredTiger.engineConfig.journalCompressor` or setting `eviction_dirty_target` to a higher value (requires server restart). Example: `db.adminCommand({setParameter:1,wiredTigerEngineConfig:{eviction_dirty_target:20}})`",
      "success_rate": 0.75,
      "how": "Increase the WiredTiger snapshot retention period by adjusting the `storage.wiredTiger.engineConfig.journalCompressor` or setting `eviction_dirty_target` to a higher value (requires server restart). Example: `db.adminCommand({setParameter:1,wiredTigerEngineConfig:{eviction_dirty_target:20}})`",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using secondary reads, ensure the secondary's oplog window is large enough to support the transaction's read timestamp. Monitor with `rs.printSlaveReplicationInfo()` and increase oplog size if needed.",
      "success_rate": 0.8,
      "how": "If using secondary reads, ensure the secondary's oplog window is large enough to support the transaction's read timestamp. Monitor with `rs.printSlaveReplicationInfo()` and increase oplog size if needed.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Reduce the duration of transactions by committing them faster. Break large transactions into smaller batches. Example: instead of one transaction updating 10,000 documents, use 100 transactions of 100 documents each.",
    "Increase the WiredTiger snapshot retention period by adjusting the `storage.wiredTiger.engineConfig.journalCompressor` or setting `eviction_dirty_target` to a higher value (requires server restart). Example: `db.adminCommand({setParameter:1,wiredTigerEngineConfig:{eviction_dirty_target:20}})`",
    "If using secondary reads, ensure the secondary's oplog window is large enough to support the transaction's read timestamp. Monitor with `rs.printSlaveReplicationInfo()` and increase oplog size if needed."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/core/transactions/",
  "official_doc_section": null,
  "error_code": "262",
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.82,
  "resolvable": "partial",
  "first_seen": "2024-01-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}