[jira] [Commented] (FLINK-35217) Missing fsync in FileSystemCheckpointStorage
[ https://issues.apache.org/jira/browse/FLINK-35217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17842363#comment-17842363 ] Roman Khachatryan commented on FLINK-35217: --- [~srichter] would you mind backporting the fix to previous releases? It should at least be ported to one previous release according to support policy, ideally to two. > Missing fsync in FileSystemCheckpointStorage > > > Key: FLINK-35217 > URL: https://issues.apache.org/jira/browse/FLINK-35217 > Project: Flink > Issue Type: Bug > Components: FileSystems, Runtime / Checkpointing >Affects Versions: 1.17.0, 1.18.0, 1.19.0 >Reporter: Marc Aurel Fritz >Assignee: Stefan Richter >Priority: Critical > Labels: pull-request-available > Fix For: 1.20.0 > > > While running Flink on a system with unstable power supply checkpoints were > regularly corrupted in the form of "_metadata" files with a file size of 0 > bytes. In all cases the previous checkpoint data had already been deleted, > causing progress to be lost completely. > Further investigation revealed that the "FileSystemCheckpointStorage" doesn't > perform "fsync" when writing a new checkpoint to disk. This means the old > checkpoint gets removed without making sure that the new one is durably > persisted on disk. "strace" on the jobmanager's process confirms this > behavior: > # The checkpoint chk-60's in-progress metadata is written at "openat" > # The checkpoint chk-60's in-progress metadata is atomically renamed at > "rename" > # The old checkpoint chk-59 is deleted at "unlink" > For durable persistence an "fsync" call is missing before step 3. > Full "strace" log: > {code:java} > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fc970) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fca00) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc", > {st_mode=S_IFDIR|0755, st_size=42, ...}) = 0 > [pid 51618] 11:44:30 > mkdir("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", 0777) > = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc860) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc740) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > 0x7fd2ad5fc7d0) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > O_WRONLY|O_CREAT|O_EXCL, 0666) = 168 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51618] 11:44:30 > rename("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata") = > 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51644] 11:44:30 > unlink("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata") > = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 168 > [pid 51644] 11:44:30 newfstatat(168, "", {st_mode=S_IFDIR|0755, st_size=0, > ...}, AT_EMPTY_PATH) = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d
[jira] [Commented] (FLINK-35217) Missing fsync in FileSystemCheckpointStorage
[ https://issues.apache.org/jira/browse/FLINK-35217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17842587#comment-17842587 ] Roman Khachatryan commented on FLINK-35217: --- Backported to 1.18 as e6726d3b962383d9a2576fe117d7566b205f514a and to 1.19 as ac4aa35c6e2e2da87760ffbf45d85888b1976c2f. > Missing fsync in FileSystemCheckpointStorage > > > Key: FLINK-35217 > URL: https://issues.apache.org/jira/browse/FLINK-35217 > Project: Flink > Issue Type: Bug > Components: FileSystems, Runtime / Checkpointing >Affects Versions: 1.17.0, 1.18.0, 1.19.0 >Reporter: Marc Aurel Fritz >Assignee: Stefan Richter >Priority: Critical > Labels: pull-request-available > Fix For: 1.18.2, 1.20.0, 1.19.1 > > > While running Flink on a system with unstable power supply checkpoints were > regularly corrupted in the form of "_metadata" files with a file size of 0 > bytes. In all cases the previous checkpoint data had already been deleted, > causing progress to be lost completely. > Further investigation revealed that the "FileSystemCheckpointStorage" doesn't > perform "fsync" when writing a new checkpoint to disk. This means the old > checkpoint gets removed without making sure that the new one is durably > persisted on disk. "strace" on the jobmanager's process confirms this > behavior: > # The checkpoint chk-60's in-progress metadata is written at "openat" > # The checkpoint chk-60's in-progress metadata is atomically renamed at > "rename" > # The old checkpoint chk-59 is deleted at "unlink" > For durable persistence an "fsync" call is missing before step 3. > Full "strace" log: > {code:java} > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fc970) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fca00) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc", > {st_mode=S_IFDIR|0755, st_size=42, ...}) = 0 > [pid 51618] 11:44:30 > mkdir("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", 0777) > = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc860) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc740) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > 0x7fd2ad5fc7d0) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > O_WRONLY|O_CREAT|O_EXCL, 0666) = 168 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51618] 11:44:30 > rename("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata") = > 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51644] 11:44:30 > unlink("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata") > = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 168 > [pid 51644] 11:44:30 newfstatat(168, "", {st_mode=S_IFDIR|0755, st_size=0, > ...}, AT_EMPTY_PATH) = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > O_RDONLY
[jira] [Commented] (FLINK-35217) Missing fsync in FileSystemCheckpointStorage
[ https://issues.apache.org/jira/browse/FLINK-35217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17840115#comment-17840115 ] Stefan Richter commented on FLINK-35217: Hi, the code is calling close on the output stream which usually implies that it's flushed and synced. I'm wondering if this is a OS or Java version specific problem? > Missing fsync in FileSystemCheckpointStorage > > > Key: FLINK-35217 > URL: https://issues.apache.org/jira/browse/FLINK-35217 > Project: Flink > Issue Type: Bug > Components: FileSystems, Runtime / Checkpointing >Affects Versions: 1.17.0, 1.18.0, 1.19.0 >Reporter: Marc Aurel Fritz >Priority: Critical > > While running Flink on a system with unstable power supply checkpoints were > regularly corrupted in the form of "_metadata" files with a file size of 0 > bytes. In all cases the previous checkpoint data had already been deleted, > causing progress to be lost completely. > Further investigation revealed that the "FileSystemCheckpointStorage" doesn't > perform "fsync" when writing a new checkpoint to disk. This means the old > checkpoint gets removed without making sure that the new one is durably > persisted on disk. "strace" on the jobmanager's process confirms this > behavior: > # The checkpoint chk-60's in-progress metadata is written at "openat" > # The checkpoint chk-60's in-progress metadata is atomically renamed at > "rename" > # The old checkpoint chk-59 is deleted at "unlink" > For durable persistence an "fsync" call is missing before step 3. > Full "strace" log: > {code:java} > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fc970) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fca00) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc", > {st_mode=S_IFDIR|0755, st_size=42, ...}) = 0 > [pid 51618] 11:44:30 > mkdir("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", 0777) > = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc860) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc740) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > 0x7fd2ad5fc7d0) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > O_WRONLY|O_CREAT|O_EXCL, 0666) = 168 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51618] 11:44:30 > rename("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata") = > 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51644] 11:44:30 > unlink("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata") > = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 168 > [pid 51644] 11:44:30 newfstatat(168, "", {st_mode=S_IFDIR|0755, st_size=0, > ...}, AT_EMPTY_PATH) = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 168 > [pid 51644] 11:44:30 newfstatat(168, "", {st_mod
[jira] [Commented] (FLINK-35217) Missing fsync in FileSystemCheckpointStorage
[ https://issues.apache.org/jira/browse/FLINK-35217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17840154#comment-17840154 ] Marc Aurel Fritz commented on FLINK-35217: -- Hey there, thanks for the quick response! I've checked the docs and it doesn't seem like the OutputStream gives any guarantees on data persistence when calling close(). The doc only states that close() frees resources. For java 17 this can be found e.g. here: [https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/OutputStream.html#close()] It may be possible that the actual behavior changed with the recent switch to java 17, however the documentation states the same for java 11 and 17. All things considered I'm quite sure we cannot safely rely on OutputStream's close() method for data durability as there don't seem to be any guarantees. The flink job was deployed using podman with this exact base image from docker hub: {code:java} flink:1.19.0-scala_2.12-java17@sha256:4135661d32caae437ba1a6d328e95910800c640e078bb49ee3789bdccd8a7792 {code} It's a standalone deployment of one jobmanager and one taskmanager container. The straces were recorded on fedora kinoite with kernel version 6.7. If it's of any help I can also get an strace of an older flink 1.17 / java 11 version of the job. > Missing fsync in FileSystemCheckpointStorage > > > Key: FLINK-35217 > URL: https://issues.apache.org/jira/browse/FLINK-35217 > Project: Flink > Issue Type: Bug > Components: FileSystems, Runtime / Checkpointing >Affects Versions: 1.17.0, 1.18.0, 1.19.0 >Reporter: Marc Aurel Fritz >Priority: Critical > > While running Flink on a system with unstable power supply checkpoints were > regularly corrupted in the form of "_metadata" files with a file size of 0 > bytes. In all cases the previous checkpoint data had already been deleted, > causing progress to be lost completely. > Further investigation revealed that the "FileSystemCheckpointStorage" doesn't > perform "fsync" when writing a new checkpoint to disk. This means the old > checkpoint gets removed without making sure that the new one is durably > persisted on disk. "strace" on the jobmanager's process confirms this > behavior: > # The checkpoint chk-60's in-progress metadata is written at "openat" > # The checkpoint chk-60's in-progress metadata is atomically renamed at > "rename" > # The old checkpoint chk-59 is deleted at "unlink" > For durable persistence an "fsync" call is missing before step 3. > Full "strace" log: > {code:java} > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fc970) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fca00) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc", > {st_mode=S_IFDIR|0755, st_size=42, ...}) = 0 > [pid 51618] 11:44:30 > mkdir("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", 0777) > = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc860) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc740) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > 0x7fd2ad5fc7d0) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > O_WRONLY|O_CREAT|O_EXCL, 0666) = 168 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51618] 11:44:30 > rename("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata") = > 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51644] 11:44:30 > unlink("/opt/flink/statestore/e1
[jira] [Commented] (FLINK-35217) Missing fsync in FileSystemCheckpointStorage
[ https://issues.apache.org/jira/browse/FLINK-35217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17840787#comment-17840787 ] Stefan Richter commented on FLINK-35217: I think you are right, close will only guarantee a flush, i.e. passing all data to the OS, but not forcing the OS to write to disk. > Missing fsync in FileSystemCheckpointStorage > > > Key: FLINK-35217 > URL: https://issues.apache.org/jira/browse/FLINK-35217 > Project: Flink > Issue Type: Bug > Components: FileSystems, Runtime / Checkpointing >Affects Versions: 1.17.0, 1.18.0, 1.19.0 >Reporter: Marc Aurel Fritz >Priority: Critical > > While running Flink on a system with unstable power supply checkpoints were > regularly corrupted in the form of "_metadata" files with a file size of 0 > bytes. In all cases the previous checkpoint data had already been deleted, > causing progress to be lost completely. > Further investigation revealed that the "FileSystemCheckpointStorage" doesn't > perform "fsync" when writing a new checkpoint to disk. This means the old > checkpoint gets removed without making sure that the new one is durably > persisted on disk. "strace" on the jobmanager's process confirms this > behavior: > # The checkpoint chk-60's in-progress metadata is written at "openat" > # The checkpoint chk-60's in-progress metadata is atomically renamed at > "rename" > # The old checkpoint chk-59 is deleted at "unlink" > For durable persistence an "fsync" call is missing before step 3. > Full "strace" log: > {code:java} > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fc970) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > 0x7fd2ad5fca00) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc", > {st_mode=S_IFDIR|0755, st_size=42, ...}) = 0 > [pid 51618] 11:44:30 > mkdir("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", 0777) > = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc860) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata", > 0x7fd2ad5fc740) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > 0x7fd2ad5fc7d0) = -1 ENOENT (No such file or directory) > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51618] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > O_WRONLY|O_CREAT|O_EXCL, 0666) = 168 > [pid 51618] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51618] 11:44:30 > rename("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/._metadata.inprogress.bf9518dc-2100-4524-9e67-e42913c2b8e8", > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-60/_metadata") = > 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata", > {st_mode=S_IFREG|0644, st_size=23378, ...}) = 0 > [pid 51644] 11:44:30 > unlink("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59/_metadata") > = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 168 > [pid 51644] 11:44:30 newfstatat(168, "", {st_mode=S_IFDIR|0755, st_size=0, > ...}, AT_EMPTY_PATH) = 0 > [pid 51644] 11:44:30 > stat("/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 > [pid 51644] 11:44:30 openat(AT_FDCWD, > "/opt/flink/statestore/e1c541c4568515e77df32d82727e20dc/chk-59", > O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 168 > [pid 51644] 11:44:30 newfstatat(168, "", {st_mode=S_IFDIR|0755, st_size=0, > ...},