Avro
  1. Avro
  2. AVRO-1055

Race condition in Java fingerprinting code

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.0
    • Fix Version/s: 1.6.3
    • Component/s: java
    • Labels:
      None

      Description

      There is a subtle race condition. If the fpTable64 is not yet initialized and two thread try to compute FP for two schemas (or the same schema) at the same time, one thread will start initializing the table while the other can start using the partially initialized table giving wrong result.

      The forthcoming patch fixes that issue

      1. AVRO-1055.patch
        1 kB
        Thiruvalluvan M. G.

        Activity

        Thiruvalluvan M. G. created issue -
        Hide
        Thiruvalluvan M. G. added a comment -

        This patch solves the problem by making the FP table a static array and initializing it in a static block. Java ensures that nobody is able to access the table until it is fully initialized.

        By making it a static member of an inner static class rather than SchemaNormalization class itself, we ensure that the Table is initialized only when it is required. (the class loader will load the inner class only when the table is accessed for the first time)

        Show
        Thiruvalluvan M. G. added a comment - This patch solves the problem by making the FP table a static array and initializing it in a static block. Java ensures that nobody is able to access the table until it is fully initialized. By making it a static member of an inner static class rather than SchemaNormalization class itself, we ensure that the Table is initialized only when it is required. (the class loader will load the inner class only when the table is accessed for the first time)
        Thiruvalluvan M. G. made changes -
        Field Original Value New Value
        Attachment AVRO-1055.patch [ 12521815 ]
        Thiruvalluvan M. G. made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Hide
        Doug Cutting added a comment -

        +1 Looks good to me. You might add a comment saying something like, "Nested class used so that table is not built unless it's used."

        Show
        Doug Cutting added a comment - +1 Looks good to me. You might add a comment saying something like, "Nested class used so that table is not built unless it's used."
        Hide
        Thiruvalluvan M. G. added a comment -

        Included the comment as suggested by Doug.
        Committed revision 1325207. Thank you Doug for reviewing.

        Show
        Thiruvalluvan M. G. added a comment - Included the comment as suggested by Doug. Committed revision 1325207. Thank you Doug for reviewing.
        Thiruvalluvan M. G. made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Doug Cutting made changes -
        Fix Version/s 1.6.3 [ 12319869 ]
        Doug Cutting made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        5m 32s 1 Thiruvalluvan M. G. 07/Apr/12 13:23
        Patch Available Patch Available Resolved Resolved
        4d 23h 3m 1 Thiruvalluvan M. G. 12/Apr/12 12:27
        Resolved Resolved Closed Closed
        166d 9h 57m 1 Doug Cutting 25/Sep/12 22:24

          People

          • Assignee:
            Thiruvalluvan M. G.
            Reporter:
            Thiruvalluvan M. G.
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development