Hadoop HDFS
  1. Hadoop HDFS
  2. HDFS-3574

Fix small race and do some cleanup in GetImageServlet


    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 2.0.2-alpha
    • Component/s: namenode
    • Labels:


      There's a very small race window in GetImageServlet, if the following interleaving occurs:

      • The Storage object returns some local file in the storage directory (eg an edits file or image file)
      • Race: some other process removes the file
      • GetImageServlet calls file.length() which returns 0, since it doesn't exist. It thus faithfully sets the Content-Length header to 0
      • getFileClient() throws FileNotFoundException when trying to open the file. But, since we call response.getOutputStream() before this, the headers have already been sent, so we fail to send the "404" or "500" response that we should.

      Thus, the client sees a 0-length Content-Length followed by 0 lengths of content, and thinks it successfully has downloaded the target file, where in fact it downloads an empty one.

      I saw this in practice during the "edits synchronization" phase of recovery while working on HDFS-3077, though it could apply on existing code paths, as well, I believe.

      1. hdfs-3574.txt
        10 kB
        Todd Lipcon
      2. hdfs-3574.txt
        11 kB
        Todd Lipcon
      3. hdfs-3574.txt
        10 kB
        Todd Lipcon
      4. hdfs-3574.txt
        10 kB
        Todd Lipcon


        No work has yet been logged on this issue.


          • Assignee:
            Todd Lipcon
            Todd Lipcon
          • Votes:
            0 Vote for this issue
            6 Start watching this issue


            • Created: