Example #1
0
    void CachedPlanRunner::updateCache() {
        _updatedCache = true;

        if (_killed) {
            return;
        }

        Database* db = cc().database();
        // XXX: We need to check for NULL because this is called upon
        // destruction of the CachedPlanRunner. In some cases, the db
        // or collection could be dropped without kill() being called
        // on the runner (for example, timeout of a ClientCursor holding
        // the runner).
        if (NULL == db) { return; }
        Collection* collection = db->getCollection(_canonicalQuery->ns());
        if (NULL == collection) { return; }
        PlanCache* cache = collection->infoCache()->getPlanCache();

        std::auto_ptr<PlanCacheEntryFeedback> feedback(new PlanCacheEntryFeedback());
        // XXX: what else can we provide here?
        feedback->stats.reset(_exec->getStats());
        feedback->score = PlanRanker::scoreTree(feedback->stats.get());

        Status fbs = cache->feedback(*_canonicalQuery, feedback.release());

        if (!fbs.isOK()) {
            QLOG() << _canonicalQuery->ns() << ": Failed to update cache with feedback: "
                   << fbs.toString() << " - "
                   << "(query: " << _canonicalQuery->getQueryObj()
                   << "; sort: " << _canonicalQuery->getParsed().getSort()
                   << "; projection: " << _canonicalQuery->getParsed().getProj()
                   << ") is no longer in plan cache.";
        }
    }
Example #2
0
    void CachedPlanRunner::updateCache() {
        _updatedCache = true;

        // We're done.  Update the cache.
        PlanCache* cache = PlanCache::get(_canonicalQuery->ns());

        // TODO: Is this an error?
        if (NULL == cache) { return; }

        // TODO: How do we decide this?
        bool shouldRemovePlan = false;

        if (shouldRemovePlan) {
            if (!cache->remove(*_canonicalQuery, *_cachedQuery->solution)) {
                warning() << "Cached plan runner couldn't remove plan from cache.  Maybe"
                    " somebody else did already?";
                return;
            }
        }

        // We're done running.  Update cache.
        auto_ptr<CachedSolutionFeedback> feedback(new CachedSolutionFeedback());
        feedback->stats = _exec->getStats();
        cache->feedback(*_canonicalQuery, *_cachedQuery->solution, feedback.release());
    }
Example #3
0
void CachedPlanStage::updatePlanCache() {
    const double score = PlanRanker::scoreTree(getStats()->children[0].get());

    PlanCache* cache = collection()->infoCache()->getPlanCache();
    Status fbs = cache->feedback(*_canonicalQuery, score);
    if (!fbs.isOK()) {
        LOG(5) << _canonicalQuery->ns() << ": Failed to update cache with feedback: " << redact(fbs)
               << " - "
               << "(query: " << redact(_canonicalQuery->getQueryObj())
               << "; sort: " << _canonicalQuery->getQueryRequest().getSort()
               << "; projection: " << _canonicalQuery->getQueryRequest().getProj()
               << ") is no longer in plan cache.";
    }
}
Example #4
0
void CachedPlanStage::updatePlanCache() {
    std::unique_ptr<PlanCacheEntryFeedback> feedback = stdx::make_unique<PlanCacheEntryFeedback>();
    feedback->stats = getStats();
    feedback->score = PlanRanker::scoreTree(feedback->stats.get());

    PlanCache* cache = _collection->infoCache()->getPlanCache();
    Status fbs = cache->feedback(*_canonicalQuery, feedback.release());
    if (!fbs.isOK()) {
        LOG(5) << _canonicalQuery->ns()
               << ": Failed to update cache with feedback: " << fbs.toString() << " - "
               << "(query: " << _canonicalQuery->getQueryObj()
               << "; sort: " << _canonicalQuery->getParsed().getSort()
               << "; projection: " << _canonicalQuery->getParsed().getProj()
               << ") is no longer in plan cache.";
    }
}
    void CachedPlanRunner::updateCache() {
        _updatedCache = true;

        Database* db = cc().database();
        verify(NULL != db);
        Collection* collection = db->getCollection(_canonicalQuery->ns());
        verify(NULL != collection);
        PlanCache* cache = collection->infoCache()->getPlanCache();

        std::auto_ptr<PlanCacheEntryFeedback> feedback(new PlanCacheEntryFeedback());
        // XXX: what else can we provide here?
        feedback->stats.reset(_exec->getStats());
        feedback->score = PlanRanker::scoreTree(feedback->stats.get());

        Status fbs = cache->feedback(*_canonicalQuery, feedback.release());

        if (!fbs.isOK()) {
            // XXX: what should happen here?
            warning() << "Failed to update cache with feedback: " << fbs.toString() << endl;
        }
    }