Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-34855

AtomicFileWriter isn't Atomic

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Issue Links

            Activity

            Hide
            batmat Baptiste Mathus added a comment -

            Once merged & released, this should probably be picked up in next LTS only once/if JENKINS-48407 is fixed too.

            Show
            batmat Baptiste Mathus added a comment - Once merged & released, this should probably be picked up in next LTS only once/if  JENKINS-48407 is fixed too.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Baptiste Mathus
            Path:
            core/src/main/java/hudson/util/FileChannelWriter.java
            core/src/test/java/hudson/util/FileChannelWriterTest.java
            http://jenkins-ci.org/commit/jenkins/22efbad9450fc95748e0bc3bee04ec49702d7ed2
            Log:
            JENKINS-34855 Create a FileChannelWriter

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Baptiste Mathus Path: core/src/main/java/hudson/util/FileChannelWriter.java core/src/test/java/hudson/util/FileChannelWriterTest.java http://jenkins-ci.org/commit/jenkins/22efbad9450fc95748e0bc3bee04ec49702d7ed2 Log: JENKINS-34855 Create a FileChannelWriter
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Baptiste Mathus
            Path:
            core/src/main/java/hudson/util/AtomicFileWriter.java
            core/src/main/java/hudson/util/FileChannelWriter.java
            core/src/test/java/hudson/util/FileChannelWriterTest.java
            test/src/test/java/hudson/util/AtomicFileWriterPerfTest.java
            http://jenkins-ci.org/commit/jenkins/438e9296f0646d920e19e05c7696d8cec5307a88
            Log:
            Merge pull request #3170 from batmat/JENKINS-34855

            [FIX JENKINS-34855] Create a FileChannelWriter and use it for AtomicFileWriter "enforced" flushing

            Compare: https://github.com/jenkinsci/jenkins/compare/02d0531add35...438e9296f064

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Baptiste Mathus Path: core/src/main/java/hudson/util/AtomicFileWriter.java core/src/main/java/hudson/util/FileChannelWriter.java core/src/test/java/hudson/util/FileChannelWriterTest.java test/src/test/java/hudson/util/AtomicFileWriterPerfTest.java http://jenkins-ci.org/commit/jenkins/438e9296f0646d920e19e05c7696d8cec5307a88 Log: Merge pull request #3170 from batmat/ JENKINS-34855 [FIX JENKINS-34855] Create a FileChannelWriter and use it for AtomicFileWriter "enforced" flushing Compare: https://github.com/jenkinsci/jenkins/compare/02d0531add35...438e9296f064
            Hide
            batmat Baptiste Mathus added a comment -

            Fixed towards 2.102, expected to be released in the next ~12 hours.

            Show
            batmat Baptiste Mathus added a comment - Fixed towards 2.102, expected to be released in the next ~12 hours.
            Hide
            batmat Baptiste Mathus added a comment -

            Reminder: we must pick up JENKINS-48407 with this one if accepted for next LTS.

            Show
            batmat Baptiste Mathus added a comment - Reminder: we must pick up  JENKINS-48407 with this one if accepted for next LTS.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: