For reference, here is the current patch I have for this https://github.com/michaelmior/calcite/commit/aada6f33de92901c6df9be9f0d890903332bf8e4
It means materialized views will only be detected the first time a query is run. However, I don't see a good way to clean up otherwise. -- Michael Mior [email protected] 2016-11-03 14:03 GMT-04:00 Julian Hyde <[email protected]>: > Maryann, > > Can you comment on this? You have had to deal with the same thing in > Phoenix: registering materializations. I recall that you found it tricky to > manage the life-cycle also. How did you solve it? Do we need changes to > Calcite to make this stuff easier? (Hooks are a blunt instrument, intended > mainly for debugging, and if we overuse them I think we will see nasty side > effects such as resource leaks and thread-unsafely.) > > Julian > > > On Nov 3, 2016, at 10:58 AM, Michael Mior <[email protected]> wrote: > > > > Yup, definitely a leak as a result of my incomplete understanding of how > > Hooks work. I'll prepare a patch. > > > > -- > > Michael Mior > > [email protected] > > > > 2016-11-03 13:45 GMT-04:00 Julian Hyde <[email protected]>: > > > >> Michael, > >> > >> Coverity flagged a line of code in CassandraSchema as a resource leak. > >> Coverity noticed Hook.add returns an AutoCloseable, and this never gets > >> closed. > >> > >> It seems to me that if you created 1,000 instances of CassandraSchema, > >> there would be 1,000 entries on Hook.TRIMMED.handlers, and each would > >> reference a CassandraSchema, preventing it from being garbage > collected. Do > >> you agree that this is a resource leak? > >> > >> Julian > >> > >> > >>> Begin forwarded message: > >>> > >>> From: [email protected] > >>> Subject: New Defects reported by Coverity Scan for Apache Calcite > >>> Date: November 3, 2016 at 9:18:36 AM PDT > >>> To: [email protected] > >>> > >>> > >>> Hi, > >>> > >>> Please find the latest report on new defect(s) introduced to Apache > >> Calcite found with Coverity Scan. > >>> > >>> 1 new defect(s) introduced to Apache Calcite found with Coverity Scan. > >>> > >>> > >>> New defect(s) Reported-by: Coverity Scan > >>> Showing 1 of 1 defect(s) > >>> > >>> > >>> ** CID 138163: Resource leaks (RESOURCE_LEAK) > >>> /cassandra/src/main/java/org/apache/calcite/adapter/ > >> cassandra/CassandraSchema.java: 115 in org.apache.calcite.adapter. > >> cassandra.CassandraSchema.<init>(java.lang.String, java.lang.String, > >> java.lang.String, java.lang.String, org.apache.calcite.schema. > SchemaPlus, > >> java.lang.String)() > >>> > >>> > >>> ____________________________________________________________ > >> ____________________________________________ > >>> *** CID 138163: Resource leaks (RESOURCE_LEAK) > >>> /cassandra/src/main/java/org/apache/calcite/adapter/ > >> cassandra/CassandraSchema.java: 115 in org.apache.calcite.adapter. > >> cassandra.CassandraSchema.<init>(java.lang.String, java.lang.String, > >> java.lang.String, java.lang.String, org.apache.calcite.schema. > SchemaPlus, > >> java.lang.String)() > >>> 109 } catch (Exception e) { > >>> 110 throw new RuntimeException(e); > >>> 111 } > >>> 112 this.parentSchema = parentSchema; > >>> 113 this.name = name; > >>> 114 > >>>>>> CID 138163: Resource leaks (RESOURCE_LEAK) > >>>>>> Ignoring resource created by "org.apache.calcite.runtime. > Hook.TRIMMED.add(this.new > >> org.apache.calcite.adapter.cassandra.CassandraSchema.1())" leaks it. > >>> 115 Hook.TRIMMED.add(new Function<RelNode, Void>() { > >>> 116 public Void apply(RelNode node) { > >>> 117 CassandraSchema.this.addMaterializedViews(); > >>> 118 return null; > >>> 119 } > >>> 120 }); > >>> > >>> > >>> ____________________________________________________________ > >> ____________________________________________ > >>> To view the defects in Coverity Scan visit, > >> https://u2389337.ct.sendgrid.net/wf/click?upn=08onrYu34A- > >> 2BWcWUl-2F-2BfV0V05UPxvVjWch-2Bd2MGckcRZSbhom32dlDl11LWEm9n > >> X1GSvKD3jyAHW-2Fr0-2Bf0CMC8B0U7suqxV3BT15z-2FEszmrI-3D_ > >> imI2KYNsuEB01fwTN2GgVt7Zng1mYfKawcoWn3RVSCuZY4RTPkfDFQ2sNAlV > >> Cp7tMcvqqypSsWwh8zcNYzDsMmNS3UsrjeDLb-2B4agAn6wTVvOwTDRmy- > >> 2BrVeKvN8cOKAiAbrSBU7AdPoWmBEuL6DS34vNxNE-2Fe2fukq3sWSRQ- > >> 2F6krxur4Xh5yihZQwvT9qmnTKBGGOmZc9difA0b0phBrdQ-3D-3D > >>> > >>> To manage Coverity Scan email notifications for "[email protected]", > >> click https://u2389337.ct.sendgrid.net/wf/click?upn=08onrYu34A- > >> 2BWcWUl-2F-2BfV0V05UPxvVjWch-2Bd2MGckcRbVDbis712qZDP- > >> 2FA8y06Nq4BoCAgQyGZbR5Ka-2BtqPkbMIRa0EKakQx2V3qCI3AQ17q > >> Sid0ChoOurTSf7RECs1gZeliKSiqSYFeQV5NHgws1sYYu5KfGgq-2FqD0AylqtLo7E-3D_ > >> imI2KYNsuEB01fwTN2GgVt7Zng1mYfKawcoWn3RVSCuZY4RTPkfDFQ2sNAlV > >> Cp7tDVLIe6k-2FBMuQbxB-2FDFhFvj615xGYQ4yE4-2FBMZZ- > >> 2F7GzvaPAYEgc6eOv7klwWEDlQ8lCV5wVQzaL3TEXC447UhTTjWjLKV0NDl9 > >> yrozt6Q-2Fu-2Fjm0ah6BUdAt-2BtEzIVfZK-2BngxhkISn5LRy2BKdbvevNA-3D-3D > >>> > >> > >> > >
