Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-36564

Reconsider use of StubMongoProcessInterface when ViewCatalog validates a view pipeline

    • ALL
    • Query 2018-09-24

      When creating or modifying a view, the ViewCatalog will parse the view pipeline for validation. Doing so requires a MongoProcessInterface, and the ViewCatalog uses the stub implementation:

      view_catalog.cpp
          boost::intrusive_ptr<ExpressionContext> expCtx =
              new ExpressionContext(opCtx,
                                    request,
                                    CollatorInterface::cloneCollator(viewDef.defaultCollator()),
                                    // We can use a stub MongoProcessInterface because we are only parsing
                                    // the Pipeline for validation here. We won't do anything with the
                                    // pipeline that will require a real implementation.
                                    std::make_shared<StubMongoProcessInterface>(),
                                    std::move(resolvedNamespaces),
                                    boost::none);
      
          // Save this to a variable to avoid reading the atomic variable multiple times.
          auto currentFCV = serverGlobalParams.featureCompatibility.getVersion();
      
          // If the feature compatibility version is not 4.2, and we are validating features as master,
          // ban the use of new agg features introduced in 4.2 to prevent them from being persisted in the
          // catalog.
          if (serverGlobalParams.validateFeaturesAsMaster.load() &&
              currentFCV != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) {
              expCtx->maxFeatureCompatibilityVersion = currentFCV;
          }
          auto pipelineStatus = Pipeline::parse(viewDef.pipeline(), std::move(expCtx));
          if (!pipelineStatus.isOK()) {
              return pipelineStatus.getStatus();
          }
      

      But with the new $out improvements in 4.1 to output to a sharded collection, $out parsing requires a valid implementation of MongoProcessInterface::isSharded(). We should revisit this code to prepare for a world where $out and $lookup might require a real MongoProcessInterface for parsing.

            Assignee:
            nicholas.zolnierz@mongodb.com Nicholas Zolnierz
            Reporter:
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: