Hello! While testing the online checksum enabling feature, I discovered that basebackup can fail when it is interleaved with enabling data checksums. When the checksum enablement process finishes, we mark the checksum state as "on" before the checkpoint that flushes pages written by the worker completes. This means that a basebackup process active at this time can start verifying checksums before we flushed all checksum calculations, and can fail with checksum errors because of this. This doesn't result in a corrupt backup, the process fails, but that is still an issue.
I attached a test case and a proposed patch that solves this by recording the status of checksums at the last checkpoint when the backup starts, instead of using the current value. If checksums were not fully enabled at the beginning, we do not verify them during the backup run, even if they become enabled during it. I am not 100% happy with the shape of the patch, but I couldn't come up with a better solution even after staring at it for a long time, and I think it is at least correct and good enough. But maybe somebody has a better idea for solving this problem.
0001-basebackup-do-not-verify-checksums-on-pages-from-bef.patch
Description: Binary data
