{
  "slug": "doublewrite-buffer",
  "term": "Doublewrite buffer",
  "aliases": [
    "InnoDB doublewrite",
    "innodb_doublewrite"
  ],
  "definition": "An InnoDB doublewrite buffer stages data-page copies before their final file writes so crash recovery can repair an incomplete page write.",
  "note": "MySQL 8.4 ON and DETECT_AND_RECOVER preserve page content, while DETECT_ONLY preserves metadata without repair bytes. Changes among these enabled modes can be dynamic, but switching between an enabled mode and OFF cannot. [mysql-parameters]\n\nIn mysql-8.4.0, reduced entries contain tablespace ID, page number and LSN. Recovery can fail on a corrupt page when no full copy has repaired it. A recorded page identity is not a recovery image. [mysql-dblwr-code]\n\nRedo logging remains separate: it records changes for replay, whereas the staged page supplies reconstruction material. A successfully repaired page does not decide whether its transaction committed. [mysql-redo] [mysql-recovery]",
  "status": "shipping",
  "advantages": [
    {
      "text": "Sequential batching shares synchronization work across pages instead of requiring a separate flush per staged page.",
      "citationIds": [
        "mysql-doublewrite"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Additional page writes consume bandwidth; the mechanism is not an independent backup or protection against every corruption source.",
      "citationIds": [
        "mysql-doublewrite"
      ]
    }
  ],
  "related": [
    "torn-write",
    "full-page-write",
    "write-ahead-log",
    "database-checkpoint",
    "crash-consistency"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "citations": [
    {
      "id": "mysql-doublewrite",
      "title": "MySQL 8.4: Doublewrite Buffer, page-copy recovery and batched writes",
      "url": "https://dev.mysql.com/doc/refman/8.4/en/innodb-doublewrite-buffer.html",
      "accessed": "2026-10-16"
    },
    {
      "id": "mysql-redo",
      "title": "MySQL 8.4: Redo Log, recovery records and checkpoint progress",
      "url": "https://dev.mysql.com/doc/refman/8.4/en/innodb-redo-log.html",
      "accessed": "2026-10-16"
    },
    {
      "id": "mysql-dblwr-code",
      "title": "MySQL mysql-8.4.0: buf0dblwr.cc, reduced_recover and page recovery",
      "url": "https://github.com/mysql/mysql-server/blob/mysql-8.4.0/storage/innobase/buf/buf0dblwr.cc",
      "accessed": "2026-10-16"
    },
    {
      "id": "mysql-parameters",
      "title": "MySQL 8.4: InnoDB variables, innodb_checksum_algorithm and innodb_doublewrite",
      "url": "https://dev.mysql.com/doc/refman/8.4/en/innodb-parameters.html",
      "accessed": "2026-10-16"
    },
    {
      "id": "mysql-recovery",
      "title": "MySQL 8.4: InnoDB Recovery, redo application and background transaction rollback",
      "url": "https://dev.mysql.com/doc/refman/8.4/en/innodb-recovery.html",
      "accessed": "2026-10-16"
    },
    {
      "id": "hesela-wal",
      "title": "Hesela: WAL, checkpoints and torn pages, InnoDB doublewrite",
      "url": "https://hesela.com/analyses/wal-checkpoints-torn-pages/#innodb-doublewrite",
      "accessed": "2026-10-16"
    }
  ],
  "provenance": [
    "Behavior is scoped to the MySQL 8.4 manual and mysql-8.4.0 implementation, not all engines or future releases.",
    "The description is a documentation and code review, not a power-loss experiment or throughput benchmark."
  ],
  "updated": "2026-10-16"
}
