Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-12921

System views design leads to bad user expirience.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.8
    • 2.10
    • None
    • Release Notes Required

    Description

      Current implementation of system views has broken system behavior which is related with querying system views.

      Before 2.8 system views were available via SQL queries (if indexing is enabled). It did not depend on any configuration.

      After implementation of IGNITE-12145 system views available only if SqlViewExporterSpi is passed to IgniteConfiguration.setSystemViewExporterSpi(). Now, if an user configures some SystemViewExporterSpi then provided user configuration will rewrite default configuration and SqlViewExporterSpi won't be initialized. As result it is impossible to query system views and any query to the views fails with exception. This behavior is not obvious for the user. See tests below.

      The second problem is kind of design problem. System view is internal part of the system and should be available regardless of any exporter configuration (at least via SQL) such as it was implemented before 2.8 release.

      My suggestion is the following: we should remove SqlViewExporterSpi and configure all views on indexing module initialization. SqlViewExporterSPI also doesn't make sense because:

      • it operates by some internal API (SchemaManager, GridKernalContext, IgniteH2Indexing).
      • it doesn't allow to end user to add any new system view.

      Only thing that could be useful is a filtering. But it could be done with SQL.

      Reproducer of broken behavior:

      package org.apache.ignite.internal.processors.cache.metric;
      
      import org.apache.ignite.cache.query.SqlFieldsQuery;
      import org.apache.ignite.cluster.ClusterState;
      import org.apache.ignite.configuration.DataRegionConfiguration;
      import org.apache.ignite.configuration.DataStorageConfiguration;
      import org.apache.ignite.configuration.IgniteConfiguration;
      import org.apache.ignite.internal.IgniteEx;
      import org.apache.ignite.spi.systemview.jmx.JmxSystemViewExporterSpi;
      import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
      import org.junit.Test;
      
      import java.util.HashSet;
      import java.util.List;
      import java.util.Set;
      
      import static java.util.Arrays.asList;
      import static org.apache.ignite.internal.processors.cache.index.AbstractSchemaSelfTest.queryProcessor;
      
      public class SystemViewTest extends GridCommonAbstractTest {
      
          private static boolean useDefaultSpi;
      
          /** {@inheritDoc} */
          @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
              IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
      
              cfg.setConsistentId(igniteInstanceName);
      
              cfg.setDataStorageConfiguration(new DataStorageConfiguration()
                      .setDataRegionConfigurations(
                              new DataRegionConfiguration().setName("in-memory").setMaxSize(100L * 1024 * 1024))
                      .setDefaultDataRegionConfiguration(
                              new DataRegionConfiguration()
                                      .setPersistenceEnabled(true)));
      
              if (!useDefaultSpi) {
                  // Configure user provided system view exporter SPI.
                  cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
              }
      
              return cfg;
          }
      
          /**
           * Will executed succefully.
           */
          @Test
          public void testSystemViewWithDefaultSpi() throws Exception {
              useDefaultSpi = true;
      
              doTestSystemView();
          }
      
          /**
           * Will fail with <code>Table "VIEWS" not found</code>.
           */
          @Test
          public void testSystemViewWithCustomSpi() throws Exception {
              useDefaultSpi = false;
      
              doTestSystemView();
          }
      
          private void doTestSystemView() throws Exception {
              try (IgniteEx ignite = startGrid()) {
                  ignite.cluster().state(ClusterState.ACTIVE);
      
                  Set<String> cacheNames = new HashSet<>(asList("cache-1", "cache-2"));
      
                  for (String name : cacheNames)
                      ignite.getOrCreateCache(name);
      
                  SqlFieldsQuery qry = new SqlFieldsQuery("SELECT * FROM SYS.VIEWS");
      
                  List<List<?>> res = queryProcessor(ignite).querySqlFields(qry, true).getAll();
      
                  res.forEach(item -> log.info("VIEW FOUND: " + item));
              }
          }
      
      }
      

      Attachments

        Issue Links

          Activity

            People

              nizhikov Nikolay Izhikov
              agura Andrey N. Gura
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h