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

ReflectiveRelMetadataProvider is not thread-safe

    XMLWordPrintableJSON

Details

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

    Description

      There is a concurrency issue when a ReflectiveRelMetadataProvider is used from several queries simultaneously.

      This most often shows up in CsvTest, which fails about 1 in 12 times. Several unit tests will simultaneously fail with a stack trace similar to this:

      java.lang.AssertionError: Internal error: Error while applying rule EnumerableProjectRule, args [rel#40:LogicalProject.NONE.[](input=rel#38:Subset#1.NONE.[],JOINEDAT=$1,JOINTIME=$2,JOINTIMES=$3)]
              at org.apache.calcite.rel.AbstractRelNode.metadata(AbstractRelNode.java:272)
              at org.apache.calcite.rel.metadata.RelMetadataQuery.getNonCumulativeCost(RelMetadataQuery.java:114)
              at org.apache.calcite.plan.volcano.VolcanoPlanner.getCost(VolcanoPlanner.java:1111)
              at org.apache.calcite.plan.volcano.RelSubset.propagateCostImprovements0(RelSubset.java:363)
              at org.apache.calcite.plan.volcano.RelSubset.propagateCostImprovements(RelSubset.java:344)
              at org.apache.calcite.plan.volcano.VolcanoPlanner.addRelToSet(VolcanoPlanner.java:1826)
              at org.apache.calcite.plan.volcano.VolcanoPlanner.registerImpl(VolcanoPlanner.java:1759)
              at org.apache.calcite.plan.volcano.VolcanoPlanner.register(VolcanoPlanner.java:1016)
              at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:1036)
              at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:1939)
              at org.apache.calcite.plan.volcano.VolcanoRuleCall.transformTo(VolcanoRuleCall.java:138)
              at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:213)
              at org.apache.calcite.rel.convert.ConverterRule.onMatch(ConverterRule.java:118)
              at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:228)
              at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:807)
              at org.apache.calcite.tools.Programs$5.run(Programs.java:273)
              at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:321)
              at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:144)
              at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:281)
              at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:189)
              at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:698)
              at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:584)
              at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:554)
              at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:207)
              at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:563)
              at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:477)
              at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:110)
              at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:130)
              at org.apache.calcite.test.CsvTest.testDateType(CsvTest.java:368)

      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: