[ 
https://issues.apache.org/jira/browse/CALCITE-2146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16335156#comment-16335156
 ] 

Julian Hyde commented on CALCITE-2146:
--------------------------------------

I saw your PR, and it looks OK on first glance. But the question is, do we want 
to encourage people share clusters between threads? There are sure to be other 
problems.

> Errant CyclicMetadataException in multithreaded context
> -------------------------------------------------------
>
>                 Key: CALCITE-2146
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2146
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.15.0
>            Reporter: Paul Jackson
>            Assignee: Julian Hyde
>            Priority: Major
>
> The code that protects against cyclic metadata is not thread-safe. A typical 
> stack trace looks like:
> {{Caused by: org.apache.calcite.rel.metadata.CyclicMetadataException}}
> {{ at 
> org.apache.calcite.rel.metadata.CyclicMetadataException.<clinit>(CyclicMetadataException.java:28)}}
> {{  at GeneratedMetadataHandler_Collation.collations(Unknown Source)}}
> {{  at GeneratedMetadataHandler_Collation.collations_$(Unknown Source)}}
> {{  at GeneratedMetadataHandler_Collation.collations(Unknown Source)}}
> {{  at 
> org.apache.calcite.rel.metadata.RelMetadataQuery.collations(RelMetadataQuery.java:563)}}
> {{  at 
> org.apache.calcite.rel.metadata.RelMdCollation.collations(RelMdCollation.java:117)}}
> {{  at GeneratedMetadataHandler_Collation.collations_$(Unknown Source)}}
> {{  at GeneratedMetadataHandler_Collation.collations(Unknown Source)}}
> {{  at GeneratedMetadataHandler_Collation.collations_$(Unknown Source)}}
> {{  at GeneratedMetadataHandler_Collation.collations(Unknown Source)}}
> {{  at 
> org.apache.calcite.rel.metadata.RelMetadataQuery.collations(RelMetadataQuery.java:563)}}
> {{  at 
> org.apache.calcite.rel.metadata.RelMdCollation.project(RelMdCollation.java:207)}}
> {{  at 
> org.apache.calcite.rel.logical.LogicalProject$1.get(LogicalProject.java:117)}}
> {{  at 
> org.apache.calcite.rel.logical.LogicalProject$1.get(LogicalProject.java:115)}}
> {{ at org.apache.calcite.plan.RelTraitSet.replaceIfs(RelTraitSet.java:238)}}
> {{  at 
> org.apache.calcite.rel.logical.LogicalProject.create(LogicalProject.java:113)}}
> {{  at 
> org.apache.calcite.rel.logical.LogicalProject.create(LogicalProject.java:103)}}
> {{  at 
> org.apache.calcite.rel.core.RelFactories$ProjectFactoryImpl.createProject(RelFactories.java:127)}}
> {{  at org.apache.calcite.tools.RelBuilder.project(RelBuilder.java:1064)}}
> Generally, the use case that causes this is one where we have a set of SQL 
> templates represented as RelNodes, which we use as a starting point for 
> queries. If different threads operate on the same RelNode, they may work on 
> the same cluster, and therefore the same RelMetadataQuery instance, which 
> contains a map instance that is used to detect Cyclic Metadata.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to