Uploaded image for project: 'Kylin'
  1. Kylin
  2. KYLIN-2874

Ineffective check in CubeDesc#getInitialCuboidScheduler

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • v2.3.0
    • None
    • None

    Description

          public CuboidScheduler getInitialCuboidScheduler() {
              if (cuboidScheduler != null)
                  return cuboidScheduler;
      
              synchronized (this) {
                  if (cuboidScheduler == null) {
                      cuboidScheduler = CuboidScheduler.getInstance(this);
                  }
      

      Suppose thread 1 obtains the lock and modifies cuboidScheduler.
      This modification can be re-ordered with other correlated field assignments within this critical section at runtime. Thus, checking the value of cuboidScheduler is not an effective test that the critical section has completed unless the guarding lock is held while checking.
      When cuboidScheduler is assigned a newly constructed value, the JVM is allowed to reorder the assignment of the new reference to cuboidScheduler before any field assignments that may occur in the constructor.

      If thread 2 comes and read cuboidScheduler, it may use partially initialized object.

      Attachments

        Activity

          People

            liyang.gmt8@gmail.com liyang
            yuzhihong@gmail.com Ted Yu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: