{
  "id": "mongodb/capped-collection-deletion",
  "signature": "MongoServerError: cannot delete from a capped collection",
  "signature_zh": "MongoServerError: 无法从固定集合中删除文档",
  "regex": "cannot delete from a capped collection",
  "domain": "mongodb",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempted to delete a document from a capped collection, which only supports insertion and reading, not deletion or update without replacement.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试从固定集合中删除文档，固定集合只支持插入和读取，不支持删除或非替换的更新操作。",
  "versions": [
    {
      "version": "mongodb-3.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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": "allowDiskUse applies to aggregation pipelines, not to deletion operations on capped collections.",
      "fail_rate": 0.15,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Dropping the capped collection removes all data permanently; a workaround should preserve data if needed.",
      "fail_rate": 0.1,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The error is triggered by the operation type, not by the filter; any delete attempt on a capped collection fails.",
      "fail_rate": 0.05,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Convert the capped collection to an uncapped collection using `convertToCapped` or create a new uncapped collection and copy data via aggregation with $out. Example: `db.runCommand({ convertToCapped: 'myCollection', size: 100000 });` then drop and recreate as uncapped.",
      "success_rate": 0.85,
      "how": "Convert the capped collection to an uncapped collection using `convertToCapped` or create a new uncapped collection and copy data via aggregation with $out. Example: `db.runCommand({ convertToCapped: 'myCollection', size: 100000 });` then drop and recreate as uncapped.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `db.collection.drop()` to remove the entire capped collection (data loss) and recreate it as a regular collection with `db.createCollection('myCollection')`.",
      "success_rate": 0.95,
      "how": "Use `db.collection.drop()` to remove the entire capped collection (data loss) and recreate it as a regular collection with `db.createCollection('myCollection')`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Instead of deleting, set a TTL index or use a capped collection with a max document count to automatically age out old data. Example: `db.createCollection('logs', { capped: true, size: 5242880, max: 5000 });`",
      "success_rate": 0.9,
      "how": "Instead of deleting, set a TTL index or use a capped collection with a max document count to automatically age out old data. Example: `db.createCollection('logs', { capped: true, size: 5242880, max: 5000 });`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Convert the capped collection to an uncapped collection using `convertToCapped` or create a new uncapped collection and copy data via aggregation with $out. Example: `db.runCommand({ convertToCapped: 'myCollection', size: 100000 });` then drop and recreate as uncapped.",
    "Use `db.collection.drop()` to remove the entire capped collection (data loss) and recreate it as a regular collection with `db.createCollection('myCollection')`.",
    "Instead of deleting, set a TTL index or use a capped collection with a max document count to automatically age out old data. Example: `db.createCollection('logs', { capped: true, size: 5242880, max: 5000 });`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/core/capped-collections/",
  "official_doc_section": null,
  "error_code": "20",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}