Derby
  1. Derby
  2. DERBY-4918

Minor refactoring of SPSDescriptor

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.8.1.2
    • Fix Version/s: 10.8.1.2
    • Component/s: SQL
    • Labels:
      None

      Description

      The class SPSDescriptor is kind of hard to understand, and doesn't quite follow the pattern used by other tuple descriptors. Parts of the code don't agree with the documentation (i.e. SPS_TYPE_TRIGGER marked as not implemented)
      This issue tracks work to make the class easier to understand and to modify.
      The critical part that may need to be changed is the use of synchronized (this). The problem is that database locks are obtained within the critical regions, and in some special cases this causes deadlocks. I'm not yet certain this can be fixed at this level (only), but I'll continue investigation.

      1. derby-4918-2b-remove_setUUID.diff
        2 kB
        Kristian Waagan
      2. derby-4918-2a-remove_setUUID.diff
        2 kB
        Kristian Waagan
      3. derby-4918-1a-misc.diff
        10 kB
        Kristian Waagan
      4. derby-4918-1a-misc.stat
        0.3 kB
        Kristian Waagan

        Issue Links

          Activity

          Hide
          Kristian Waagan added a comment -

          Closing issue.

          Show
          Kristian Waagan added a comment - Closing issue.
          Hide
          Kristian Waagan added a comment -

          The deadlock I saw was actually a problem with BasicDependencyManager, not SPSDescriptor (see DERBY-4928).
          This may mean that there is nothing more to do for this issue, I'll keep the issue open for a while to see if anything more pops up.

          Show
          Kristian Waagan added a comment - The deadlock I saw was actually a problem with BasicDependencyManager, not SPSDescriptor (see DERBY-4928 ). This may mean that there is nothing more to do for this issue, I'll keep the issue open for a while to see if anything more pops up.
          Hide
          Kristian Waagan added a comment -

          Thanks, Knut.

          Attached patch 2b, which replaces the NPE with an IAE.
          Committed to trunk with revision 1042048.

          Show
          Kristian Waagan added a comment - Thanks, Knut. Attached patch 2b, which replaces the NPE with an IAE. Committed to trunk with revision 1042048.
          Hide
          Knut Anders Hatlen added a comment - - edited

          Patch 2a looks like a nice cleanup. +1

          One small nit is that some people (for instance these guys: http://pmd.sourceforge.net/rules/strictexception.html#AvoidThrowingNullPointerException ) claim that throwing a NullPointerException is confusing and recommend using IllegalArgumentException instead. Not that it's supposed to ever happen...

          [comment edited: added a space so that JIRA doesn't garble the URL]

          Show
          Knut Anders Hatlen added a comment - - edited Patch 2a looks like a nice cleanup. +1 One small nit is that some people (for instance these guys: http://pmd.sourceforge.net/rules/strictexception.html#AvoidThrowingNullPointerException ) claim that throwing a NullPointerException is confusing and recommend using IllegalArgumentException instead. Not that it's supposed to ever happen... [comment edited: added a space so that JIRA doesn't garble the URL]
          Hide
          Kristian Waagan added a comment -

          Attaching patch 2a, which removes the method setUUID.

          I made the getUUID-method synchronized as part of patch 1a. Turns out this caused a Java deadlock in one test when running with the automatic index statistics update feature.
          Investigation revealed that this method can actually be removed, which makes the uuid variable final. This allows for keeping getUUID unsynchronized.
          I did add code to fail if null is passed in as null in the constructor, where a NullPointerException will be thrown.

          suites.All passed, will run derbyall too.
          Patch ready for review.

          Show
          Kristian Waagan added a comment - Attaching patch 2a, which removes the method setUUID. I made the getUUID-method synchronized as part of patch 1a. Turns out this caused a Java deadlock in one test when running with the automatic index statistics update feature. Investigation revealed that this method can actually be removed, which makes the uuid variable final. This allows for keeping getUUID unsynchronized. I did add code to fail if null is passed in as null in the constructor, where a NullPointerException will be thrown. suites.All passed, will run derbyall too. Patch ready for review.
          Hide
          Kristian Waagan added a comment -

          Committed patch 1a to trunk with revision 1041192.

          Show
          Kristian Waagan added a comment - Committed patch 1a to trunk with revision 1041192.
          Hide
          Kristian Waagan added a comment -

          Attaching patch 1a.

          Regression tests passed. Ready for review.

          Show
          Kristian Waagan added a comment - Attaching patch 1a. Regression tests passed. Ready for review.

            People

            • Assignee:
              Kristian Waagan
              Reporter:
              Kristian Waagan
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development