Bug #103211 Contribution by Facebook: Reduced Doublewrite update
Submitted: 5 Apr 2021 21:34 Modified: 24 May 2022 8:33
Reporter: FBContrib Admin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.20 OS:Any
Assigned to: CPU Architecture:Any

[5 Apr 2021 21:34] FBContrib Admin
Description:
Background innformation provided by Facebook:

Abstract:

This is an update to the contribution “Introduce a reduced doublewrite mode, handling error detection only” for MySQL 8.0.20.

Goal:
-----
Introduce an option to write only page_ids (space_id, page_num)
in doublewrite buffer and not the actual pages. This detect-only
mode helps to distinguish from known partial-write corruptions vs
disk corruption issues.
This feature will be useful in the Percona XtraDB cluster because,
on page-corruption, PXC nodes can do SST for the crashed node.

Design:
-------
In reduced doublewrite buffer mode, we store only space_id, page_num,
LSN of pages in doublewrite buffer.
Existing variable --innodb-double-write will be re-used. Currently,
ON, OFF are allowed values. We will introduce a new value REDUCED.
Variable will be dynamic but allowed combinations for dynamic mode are:
REDUCED -> ON
ON -> REDUCED
We will NOT allow the following combinations
OFF -> ON
OFF -> REDUCED
ON -> OFF
REDUCED -> OFF
A separate file will be used for reduced doublewrite buffer mode.
For batch flushes (flush_list and LRU), we will use the same file.
The file name pattern will be #ib__0.bdblwr
.bdblwr -> batch doublewrite
Single page flushes continue to be written in normal mode. ie. the
full page is written as is.
If innodb-doublewrite=REDUCED is used, and on crash recovery, if the
actual page is corrupted, we crash the server

Repo: https://github.com/mysql/mysql-server
Patch on top of 8.0.20: https://github.com/mysql/mysql-server/commit/7d10c82196c

How to repeat:
See description

Suggested fix:
See contribution code attached
[5 Apr 2021 21:34] FBContrib Admin
Reduced Doublewrite update 
(*) This code is contributed under the Facebook agreement

Contribution: fb_patch_224.txt (text/plain), 205.46 KiB.

[24 May 2022 8:33] Annamalai Gurusami
Posted by developer:
 
[NOTE: The correct WL number is 14719]

commit ae8995bb1fc76eff42e2dd0900d74b62f804bdc8
Author: Annamalai Gurusami <annamalai.gurusami@oracle.com>
Date:   Sat Feb 5 11:46:13 2022 +0100

    WL#14710: InnoDB: Introducing REDUCED double write mode (Facebook Contribution)

    Currently, there is a system variable --innodb-doublewrite to enable and
    disable doublewrite buffers.  This worklog introduces two new values for this
    system variable DETECT_ONLY and DETECT_AND_RECOVER.  The DETECT_AND_RECOVER
    value is synonymous to the ON value of this variable.

    In this detect_only mode, doublewrite buffer will only be used to detect a page
    corruption and will not be used to recover from the corruption.  The double
    write buffer will not contain the actual page contents.  This detect-only mode
    helps to distinguish from known partial-write corruptions vs disk corruption
    issues.

    This patch is contributed by Facebook.  The mode was called REDUCED in the
    patch contributed by Facebook.  We renamed the user visible name to be
    DETECT_ONLY.

    rb#26722 approved by Yasufumi Kinoshita <yasufumi.kinoshita@oracle.com>
[16 Jun 2022 13:27] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 8.0.30 release:

The innodb_doublewrite system variable, which enables or disables the
doublewrite buffer, has two new settings, DETECT_ONLY and
DETECT_AND_RECOVER. With the DETECT_ONLY setting, database page content is
not written to the doublewrite buffer, and recovery does not use the
doublewrite buffer to fix incomplete page writes. This lightweight setting
is intended for detecting incomplete page writes only. The
DETECT_AND_RECOVER setting is equivalent to the existing ON setting. 

Thanks to Facebook for the contribution.