Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1594

ConventionTraitDef.getConversionData() is not thread-safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.12.0
    • None
    • None

    Description

      Test suite hangs with several threads in WeakHashMap.get, all called from ConventionTraitDef.getConversionData and using the same table.

      It is not a deadlock; all but one threads are waiting for a lock, but the thread that has the lock and is runnable.

      Abbreviated stack trace:

      Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.72-b15 mixed mode):
      ...
      "pool-1-thread-7" #20 daemon prio=5 os_prio=0 tid=0x00007f3cf4003000 nid=0x1f12 runnable [0x00007f3d3f8f4000]
         java.lang.Thread.State: RUNNABLE
      	at java.util.WeakHashMap.expungeStaleEntries(WeakHashMap.java:341)
      	- locked <0x00000000a08d14a8> (a java.lang.ref.ReferenceQueue)
      	at java.util.WeakHashMap.getTable(WeakHashMap.java:350)
      	at java.util.WeakHashMap.get(WeakHashMap.java:397)
      	at org.apache.calcite.plan.ConventionTraitDef.getConversionData(ConventionTraitDef.java:203)
      	at org.apache.calcite.plan.ConventionTraitDef.convert(ConventionTraitDef.java:129)
      	at org.apache.calcite.plan.ConventionTraitDef.convert(ConventionTraitDef.java:46)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.changeTraitsUsingConverters(VolcanoPlanner.java:1197)
      ...
      "pool-1-thread-8" #19 daemon prio=5 os_prio=0 tid=0x00007f3cec001000 nid=0x1f11 waiting for monitor entry [0x00007f3d3f9f5000]
         java.lang.Thread.State: BLOCKED (on object monitor)
      	at java.util.WeakHashMap.expungeStaleEntries(WeakHashMap.java:319)
      	- waiting to lock <0x00000000a08d14a8> (a java.lang.ref.ReferenceQueue)
      	at java.util.WeakHashMap.getTable(WeakHashMap.java:350)
      	at java.util.WeakHashMap.get(WeakHashMap.java:397)
      	at org.apache.calcite.plan.ConventionTraitDef.getConversionData(ConventionTraitDef.java:203)
      	at org.apache.calcite.plan.ConventionTraitDef.convert(ConventionTraitDef.java:129)
      	at org.apache.calcite.plan.ConventionTraitDef.convert(ConventionTraitDef.java:46)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.changeTraitsUsingConverters(VolcanoPlanner.java:1197)
      ...
      "pool-1-thread-6" #17 daemon prio=5 os_prio=0 tid=0x00007f3ce8001000 nid=0x1f0f waiting for monitor entry [0x00007f3d3fbf8000]
         java.lang.Thread.State: BLOCKED (on object monitor)
      	at java.util.WeakHashMap.expungeStaleEntries(WeakHashMap.java:319)
      	- waiting to lock <0x00000000a08d14a8> (a java.lang.ref.ReferenceQueue)
      	at java.util.WeakHashMap.getTable(WeakHashMap.java:350)
      	at java.util.WeakHashMap.get(WeakHashMap.java:397)
      	at org.apache.calcite.plan.ConventionTraitDef.getConversionData(ConventionTraitDef.java:203)
      ...
      

      Hypothesis: we should be synchronizing access to ConventionTraitDef.plannerConversionMap.

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: