Description
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.
Attachments
Issue Links
- is related to
-
CALCITE-1681 Provide a way to copy RelNode trees between clusters
- Open