The implementation of AtomicFileWriter is not actually atomic.

      There are several issues with it.

      1. the rename first deletes the target giving a window of opportunity for no file to exist.
      2. the rename of the file will rename the file but the data in the file may not have been flushed to disk. In XFS this is a biggy as the metadata and filedata are written separatly - so despite the file being closed there is not fsync call - so if the system crashes you end up with zero length files.
        This has been observed in the wild when the OS hosting jenkins crashed, on restart several of Jenkins files were zero length.

      Jenkins should make use of java.nio to make sure

      1. data is actually synced
      2. it uses atomic operations for move on platforms where it is available.

          [JENKINS-34855] AtomicFileWriter isn't Atomic

          James Nord created issue -
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 171052 ] New: JNJira + In-Review [ 184143 ]
          Jesse Glick made changes -
          Link New: This issue relates to JENKINS-36088 [ JENKINS-36088 ]
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Jesse Glick made changes -
          Assignee New: Steven Christou [ schristou ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "PR 2548 (Web Link)" [ 14872 ]
          Jesse Glick made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

          Michael Neale added a comment -

          yes this would be very good. Good catch teilo - I believe this has been the underlying problem of a lot of things (I might have to take back the bad things I said about xfs, as this seems more likely to be the problem of a block consistent snapshot without xfs_freeze).

          Very nice!

          Michael Neale added a comment - yes this would be very good. Good catch teilo - I believe this has been the underlying problem of a lot of things (I might have to take back the bad things I said about xfs, as this seems more likely to be the problem of a block consistent snapshot without xfs_freeze). Very nice!
          James Nord made changes -
          Link New: This issue relates to JENKINS-47324 [ JENKINS-47324 ]
          James Nord made changes -
          Status Original: In Review [ 10005 ] New: In Progress [ 3 ]

            batmat Baptiste Mathus
            teilo James Nord
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: