Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-10183

Prevent race condition during class initialization

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.9.0
    • 2.8.4, 3.2.0, 3.1.1, 2.9.2, 3.0.3
    • fs
    • None
    • Reviewed
    • Patch

    Description

      In HADOOP-11969, busbey tracked down a non-deterministic NullPointerException to an oddity in the Java memory model: When multiple threads trigger the loading of a class at the same time, one of them wins and creates the java.lang.Class instance; the others block during this initialization, but once it is complete they may obtain a reference to the Class which has non-final fields still containing their default (i.e. null) values. This leads to runtime failures that are hard to debug or diagnose.

      HADOOP-11969 observed that ThreadLocal fields, by their very nature, are very likely to be accessed from multiple threads, and thus the problem is particularly severe there. Consequently, the patch removed all occurrences of the issue in the code base.

      Unfortunately, since then HDFS-7964 has reverted one of the fixes during a refactoring, and introduced a new instance of the problem.

      The attached patch addresses the issue by adding the missing final modifier in these two cases.

      Attachments

        1. HADOOP-12944.1.patch
          2 kB
          Pavel Avgustinov
        2. HDFS-10183.2.patch
          3 kB
          Pavel Avgustinov

        Activity

          People

            pavgustinov Pavel Avgustinov
            pavgustinov Pavel Avgustinov
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: