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

RelMetadataTest#testMetadataHandlerCacheLimit takes 8-20 seconds and it looks useless

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.17.0
    • Fix Version/s: 1.18.0
    • Component/s: core
    • Labels:
      None

      Description

      org.apache.calcite.test.RelMetadataTest#testMetadataHandlerCacheLimit was introduced in CALCITE-1808

      Travis takes 17 seconds to execute RelMetadataTest

      [INFO] Running org.apache.calcite.test.RelMetadataTest
      [WARNING] Tests run: 140, Failures: 0, Errors: 0, Skipped: 6, Time elapsed: 17.318 s - in 
        /** Test case for
         * <a href="https://issues.apache.org/jira/browse/CALCITE-1808">[CALCITE-1808]
         * JaninoRelMetadataProvider loading cache might cause
         * OutOfMemoryError</a>. */
        @Test public void testMetadataHandlerCacheLimit() {
          Assume.assumeTrue("If cache size is too large, this test may fail and the "
                  + "test won't be to blame",
              SaffronProperties.INSTANCE.metadataHandlerCacheMaximumSize().get()
                  < 10_000);
          final int iterationCount = 2_000;
          final RelNode rel = convertSql("select * from emp");
          final RelMetadataProvider metadataProvider =
              rel.getCluster().getMetadataProvider();
          final RelOptPlanner planner = rel.getCluster().getPlanner();
          for (int i = 0; i < iterationCount; i++) {
            RelMetadataQuery.THREAD_PROVIDERS.set(
                JaninoRelMetadataProvider.of(
                    new CachingRelMetadataProvider(metadataProvider, planner)));
            final RelMetadataQuery mq = RelMetadataQuery.instance();
            final Double result = mq.getRowCount(rel);
            assertThat(result, within(14d, 0.1d));
          }
        }
      

      In fact, it creates 1000 metadata providers, and it does take noticeable time (e.g. 8 seconds on my notebook).

      I suggest to remove the test as it spends noticeable time, and it never reproduces "out of memory".

      Technically speaking the test tries to validate if org.apache.calcite.rel.metadata.JaninoRelMetadataProvider cache is bounded, however there's no assertions.

      Alternative option would be to significantly increase the number of iterations, and disable the test by default

        Attachments

          Activity

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              vladimirsitnikov Vladimir Sitnikov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: