You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/06/22 10:54:46 UTC

[GitHub] [shardingsphere] strongduanmu commented on issue #10908: RelSubset has wrong best cost error occur when execute federate query with shardingsphere-integration-test-suite

strongduanmu commented on issue #10908:
URL: https://github.com/apache/shardingsphere/issues/10908#issuecomment-865881018


   As can be seen from the `VolcanoPlanner` source code, this exception will only be checked when `isDebugEnabled=true`. This problem can be avoided by adjusting the log level.
   
   ```java
     public RelSubset ensureRegistered(RelNode rel, RelNode equivRel) {
       RelSubset result;
       final RelSubset subset = getSubset(rel);
       if (subset != null) {
         if (equivRel != null) {
           final RelSubset equivSubset = getSubset(equivRel);
           if (subset.set != equivSubset.set) {
             merge(equivSubset.set, subset.set);
           }
         }
         result = canonize(subset);
       } else {
         result = register(rel, equivRel);
       }
   
       // Checking if tree is valid considerably slows down planning
       // Only doing it if logger level is debug or finer
       if (LOGGER.isDebugEnabled()) {
         assert isValid(Litmus.THROW);
       }
   
       return result;
     }
   
     /**
      * Checks internal consistency.
      */
     protected boolean isValid(Litmus litmus) {
       if (this.getRoot() == null) {
         return true;
       }
   
       RelMetadataQuery metaQuery = this.getRoot().getCluster().getMetadataQuerySupplier().get();
       for (RelSet set : allSets) {
         if (set.equivalentSet != null) {
           return litmus.fail("set [{}] has been merged: it should not be in the list", set);
         }
         for (RelSubset subset : set.subsets) {
           if (subset.set != set) {
             return litmus.fail("subset [{}] is in wrong set [{}]",
                 subset, set);
           }
   
           if (subset.best != null) {
   
             // Make sure best RelNode is valid
             if (!subset.set.rels.contains(subset.best)) {
               return litmus.fail("RelSubset [{}] does not contain its best RelNode [{}]",
                       subset, subset.best);
             }
   
             // Make sure bestCost is up-to-date
             try {
               RelOptCost bestCost = getCost(subset.best, metaQuery);
               if (!subset.bestCost.equals(bestCost)) {
                 return litmus.fail("RelSubset [" + subset
                         + "] has wrong best cost "
                         + subset.bestCost + ". Correct cost is " + bestCost);
               }
             } catch (CyclicMetadataException e) {
               // ignore
             }
           }
   
           for (RelNode rel : subset.getRels()) {
             try {
               RelOptCost relCost = getCost(rel, metaQuery);
               if (relCost.isLt(subset.bestCost)) {
                 return litmus.fail("rel [{}] has lower cost {} than "
                         + "best cost {} of subset [{}]",
                         rel, relCost, subset.bestCost, subset);
               }
             } catch (CyclicMetadataException e) {
               // ignore
             }
           }
         }
       }
       return litmus.succeed();
     }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org