diff options
author | James Wahlin <james.wahlin@10gen.com> | 2015-03-13 10:59:13 -0400 |
---|---|---|
committer | Jason Rassi <rassi@10gen.com> | 2015-03-13 14:38:59 -0400 |
commit | ae97946ae529ea55ac610956d395c108fdea167b (patch) | |
tree | b73e97e98a598bf3c142b221c085f84750a358e6 | |
parent | 7f73e3e38f9b606574a2b7599e0b0f491b962587 (diff) | |
download | mongo-ae97946ae529ea55ac610956d395c108fdea167b.tar.gz |
SERVER-17525 Remove QLOG, replace with LOG(5)
Closes #936
Signed-off-by: Jason Rassi <rassi@10gen.com>
23 files changed, 85 insertions, 239 deletions
diff --git a/src/mongo/db/exec/cached_plan.cpp b/src/mongo/db/exec/cached_plan.cpp index 1c01f9f827d..3b8469a1368 100644 --- a/src/mongo/db/exec/cached_plan.cpp +++ b/src/mongo/db/exec/cached_plan.cpp @@ -26,6 +26,8 @@ * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery + #include "mongo/db/exec/cached_plan.h" #include "mongo/db/exec/scoped_timer.h" #include "mongo/db/exec/working_set_common.h" @@ -37,7 +39,7 @@ #include "mongo/db/client.h" #include "mongo/db/query/plan_cache.h" #include "mongo/db/query/plan_ranker.h" -#include "mongo/db/query/qlog.h" +#include "mongo/util/log.h" namespace mongo { @@ -200,7 +202,7 @@ namespace mongo { Status fbs = cache->feedback(*_canonicalQuery, feedback.release()); if (!fbs.isOK()) { - QLOG() << _canonicalQuery->ns() << ": Failed to update cache with feedback: " + LOG(5) << _canonicalQuery->ns() << ": Failed to update cache with feedback: " << fbs.toString() << " - " << "(query: " << _canonicalQuery->getQueryObj() << "; sort: " << _canonicalQuery->getParsed().getSort() diff --git a/src/mongo/db/exec/multi_plan.cpp b/src/mongo/db/exec/multi_plan.cpp index fb427c9fb46..a53a8792c68 100644 --- a/src/mongo/db/exec/multi_plan.cpp +++ b/src/mongo/db/exec/multi_plan.cpp @@ -45,7 +45,6 @@ #include "mongo/db/query/explain.h" #include "mongo/db/query/plan_cache.h" #include "mongo/db/query/plan_ranker.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/storage/record_fetcher.h" #include "mongo/util/mongoutils/str.h" #include "mongo/util/log.h" @@ -121,7 +120,7 @@ namespace mongo { StageState state = bestPlan.root->work(out); if (PlanStage::FAILURE == state && hasBackupPlan()) { - QLOG() << "Best plan errored out switching to backup\n"; + LOG(5) << "Best plan errored out switching to backup\n"; // Uncache the bad solution if we fall back // on the backup solution. // @@ -139,7 +138,7 @@ namespace mongo { } if (hasBackupPlan() && PlanStage::ADVANCED == state) { - QLOG() << "Best plan had a blocking stage, became unblocked\n"; + LOG(5) << "Best plan had a blocking stage, became unblocked\n"; _backupPlanIdx = kNoSuchPlan; } @@ -241,15 +240,15 @@ namespace mongo { std::list<WorkingSetID>& alreadyProduced = bestCandidate.results; QuerySolution* bestSolution = bestCandidate.solution; - QLOG() << "Winning solution:\n" << bestSolution->toString() << endl; + LOG(5) << "Winning solution:\n" << bestSolution->toString() << endl; LOG(2) << "Winning plan: " << Explain::getPlanSummary(bestCandidate.root); _backupPlanIdx = kNoSuchPlan; if (bestSolution->hasBlockingStage && (0 == alreadyProduced.size())) { - QLOG() << "Winner has blocking stage, looking for backup plan...\n"; + LOG(5) << "Winner has blocking stage, looking for backup plan...\n"; for (size_t ix = 0; ix < _candidates.size(); ++ix) { if (!_candidates[ix].solution->hasBlockingStage) { - QLOG() << "Candidate " << ix << " is backup child\n"; + LOG(5) << "Candidate " << ix << " is backup child\n"; _backupPlanIdx = ix; break; } @@ -336,7 +335,7 @@ namespace mongo { bool validSolutions = true; for (size_t ix = 0; ix < solutions.size(); ++ix) { if (NULL == solutions[ix]->cacheData.get()) { - QLOG() << "Not caching query because this solution has no cache data: " + LOG(5) << "Not caching query because this solution has no cache data: " << solutions[ix]->toString(); validSolutions = false; break; diff --git a/src/mongo/db/exec/sort.cpp b/src/mongo/db/exec/sort.cpp index 275f99b62db..da8c0bb57e5 100644 --- a/src/mongo/db/exec/sort.cpp +++ b/src/mongo/db/exec/sort.cpp @@ -26,6 +26,8 @@ * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery + #include "mongo/db/exec/sort.h" #include <algorithm> @@ -37,9 +39,9 @@ #include "mongo/db/exec/working_set_computed_data.h" #include "mongo/db/index/btree_key_generator.h" #include "mongo/db/query/lite_parsed_query.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_planner.h" +#include "mongo/util/log.h" namespace mongo { @@ -239,7 +241,7 @@ namespace mongo { auto_ptr<CanonicalQuery> queryForSort(rawQueryForSort); vector<QuerySolution*> solns; - QLOG() << "Sort stage: Planning to obtain bounds for sort." << endl; + LOG(5) << "Sort stage: Planning to obtain bounds for sort." << endl; QueryPlanner::plan(*queryForSort, params, &solns); // TODO: are there ever > 1 solns? If so, do we look for a specific soln? diff --git a/src/mongo/db/exec/subplan.cpp b/src/mongo/db/exec/subplan.cpp index 65f106bfdda..d86640ed3f6 100644 --- a/src/mongo/db/exec/subplan.cpp +++ b/src/mongo/db/exec/subplan.cpp @@ -26,6 +26,8 @@ * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery + #include "mongo/platform/basic.h" #include "mongo/db/exec/subplan.h" @@ -37,9 +39,9 @@ #include "mongo/db/query/plan_executor.h" #include "mongo/db/query/planner_analysis.h" #include "mongo/db/query/planner_access.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/query/stage_builder.h" +#include "mongo/util/log.h" namespace mongo { @@ -113,7 +115,7 @@ namespace mongo { for (size_t i = 0; i < _plannerParams.indices.size(); ++i) { const IndexEntry& ie = _plannerParams.indices[i]; _indexMap[ie.keyPattern] = i; - QLOG() << "Subplanner: index " << i << " is " << ie.toString() << endl; + LOG(5) << "Subplanner: index " << i << " is " << ie.toString() << endl; } const WhereCallbackReal whereCallback(_txn, _collection->ns().db()); @@ -149,14 +151,14 @@ namespace mongo { _collection->infoCache()->getPlanCache()->get(*branchResult->canonicalQuery.get(), &rawCS).isOK()) { // We have a CachedSolution. Store it for later. - QLOG() << "Subplanner: cached plan found for child " << i << " of " + LOG(5) << "Subplanner: cached plan found for child " << i << " of " << orExpr->numChildren(); branchResult->cachedSolution.reset(rawCS); } else { // No CachedSolution found. We'll have to plan from scratch. - QLOG() << "Subplanner: planning child " << i << " of " << orExpr->numChildren(); + LOG(5) << "Subplanner: planning child " << i << " of " << orExpr->numChildren(); // We don't set NO_TABLE_SCAN because peeking at the cache data will keep us from // considering any plan that's a collscan. @@ -171,7 +173,7 @@ namespace mongo { << " " << status.reason(); return Status(ErrorCodes::BadValue, ss); } - QLOG() << "Subplanner: got " << branchResult->solutions.size() << " solutions"; + LOG(5) << "Subplanner: got " << branchResult->solutions.size() << " solutions"; if (0 == branchResult->solutions.size()) { // If one child doesn't have an indexed solution, bail out. @@ -349,7 +351,7 @@ namespace mongo { return Status(ErrorCodes::BadValue, ss); } - QLOG() << "Subplanner: fully tagged tree is " << solnRoot->toString(); + LOG(5) << "Subplanner: fully tagged tree is " << solnRoot->toString(); // Takes ownership of 'solnRoot' _compositeSolution.reset(QueryPlannerAnalysis::analyzeDataAccess(*_query, @@ -362,7 +364,7 @@ namespace mongo { return Status(ErrorCodes::BadValue, ss); } - QLOG() << "Subplanner: Composite solution is " << _compositeSolution->toString() << endl; + LOG(5) << "Subplanner: Composite solution is " << _compositeSolution->toString() << endl; // Use the index tags from planning each branch to construct the composite solution, // and set that solution as our child stage. diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript index 3e5091e8e0c..6f2af6b5f2e 100644 --- a/src/mongo/db/query/SConscript +++ b/src/mongo/db/query/SConscript @@ -75,7 +75,6 @@ env.Library( "interval.cpp", ], LIBDEPS=[ - "query_logger", "$BUILD_DIR/mongo/bson", "$BUILD_DIR/mongo/expressions_geo", "$BUILD_DIR/mongo/index_names", @@ -114,16 +113,6 @@ env.Library( ], ) -env.Library( - target="query_logger", - source=[ - "qlog.cpp" - ], - LIBDEPS=[ - "$BUILD_DIR/mongo/server_parameters", - ], -) - env.CppUnitTest( target="canonical_query_test", source=[ diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index ca2b2fb7a22..4b179c19661 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -47,7 +47,6 @@ #include "mongo/db/query/find_constants.h" #include "mongo/db/query/get_executor.h" #include "mongo/db/query/internal_plans.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_planner_params.h" #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/server_options.h" @@ -231,7 +230,7 @@ namespace mongo { cursorManager = collection->getCursorManager(); } - QLOG() << "Running getMore, cursorid: " << cursorid << endl; + LOG(5) << "Running getMore, cursorid: " << cursorid << endl; // This checks to make sure the operation is allowed on a replicated node. Since we are not // passing in a query object (necessary to check SlaveOK query option), the only state where @@ -422,7 +421,7 @@ namespace mongo { // cc is now invalid, as is the executor cursorid = 0; cc = NULL; - QLOG() << "getMore NOT saving client cursor, ended with state " + LOG(5) << "getMore NOT saving client cursor, ended with state " << PlanExecutor::statestr(state) << endl; } @@ -430,7 +429,7 @@ namespace mongo { // Continue caching the ClientCursor. cc->incPos(numResults); exec->saveState(); - QLOG() << "getMore saving client cursor ended with state " + LOG(5) << "getMore saving client cursor ended with state " << PlanExecutor::statestr(state) << endl; @@ -471,7 +470,7 @@ namespace mongo { qr.setStartingFrom(startingResult); qr.setNReturned(numResults); bb.decouple(); - QLOG() << "getMore returned " << numResults << " results\n"; + LOG(5) << "getMore returned " << numResults << " results\n"; return qr; } @@ -637,7 +636,7 @@ namespace mongo { } invariant(cq.get()); - QLOG() << "Running query:\n" << cq->toString(); + LOG(5) << "Running query:\n" << cq->toString(); LOG(2) << "Running query: " << cq->toStringShort(); // Parse, canonicalize, plan, transcribe, and get a plan executor. @@ -781,13 +780,13 @@ namespace mongo { } if (enoughForFirstBatch(pq, numResults, bb.len())) { - QLOG() << "Enough for first batch, wantMore=" << pq.wantMore() + LOG(5) << "Enough for first batch, wantMore=" << pq.wantMore() << " numToReturn=" << pq.getNumToReturn() << " numResults=" << numResults << endl; // If only one result requested assume it's a findOne() and don't save the cursor. if (pq.wantMore() && 1 != pq.getNumToReturn()) { - QLOG() << " executor EOF=" << exec->isEOF() << endl; + LOG(5) << " executor EOF=" << exec->isEOF() << endl; saveClientCursor = !exec->isEOF(); } break; @@ -893,7 +892,7 @@ namespace mongo { txn->setRecoveryUnit(storageEngine->newRecoveryUnit()); } - QLOG() << "caching executor with cursorid " << ccId + LOG(5) << "caching executor with cursorid " << ccId << " after returning " << numResults << " results" << endl; // TODO document @@ -915,7 +914,7 @@ namespace mongo { cc->setLeftoverMaxTimeMicros(curop.getRemainingMaxTimeMicros()); } else { - QLOG() << "Not caching executor but returning " << numResults << " results.\n"; + LOG(5) << "Not caching executor but returning " << numResults << " results.\n"; } // Add the results from the query into the output buffer. diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index a6816017593..2d70df158ed 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -59,7 +59,6 @@ #include "mongo/db/query/plan_executor.h" #include "mongo/db/query/planner_analysis.h" #include "mongo/db/query/planner_access.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/query/query_planner_common.h" @@ -321,7 +320,6 @@ namespace mongo { if (internalQueryPlanOrChildrenIndependently && SubplanStage::canUseSubplanning(*canonicalQuery)) { - QLOG() << "Running query as sub-queries: " << canonicalQuery->toStringShort(); LOG(2) << "Running query as sub-queries: " << canonicalQuery->toStringShort(); *rootOut = new SubplanStage(opCtx, collection, ws, plannerParams, canonicalQuery); diff --git a/src/mongo/db/query/index_bounds_builder.cpp b/src/mongo/db/query/index_bounds_builder.cpp index 58aede3d936..9a5b25affd1 100644 --- a/src/mongo/db/query/index_bounds_builder.cpp +++ b/src/mongo/db/query/index_bounds_builder.cpp @@ -39,7 +39,6 @@ #include "mongo/db/query/expression_index.h" #include "mongo/db/query/expression_index_knobs.h" #include "mongo/db/query/indexability.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_knobs.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/query/plan_cache.cpp b/src/mongo/db/query/plan_cache.cpp index 4f923392dfd..e246ca27731 100644 --- a/src/mongo/db/query/plan_cache.cpp +++ b/src/mongo/db/query/plan_cache.cpp @@ -40,7 +40,6 @@ #include "mongo/client/dbclientinterface.h" // For QueryOption_foobar #include "mongo/db/query/plan_ranker.h" #include "mongo/db/query/query_solution.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_knobs.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/query/plan_cache_test.cpp b/src/mongo/db/query/plan_cache_test.cpp index 8ebb9221029..dc9d4bc8f42 100644 --- a/src/mongo/db/query/plan_cache_test.cpp +++ b/src/mongo/db/query/plan_cache_test.cpp @@ -39,7 +39,6 @@ #include "mongo/db/jsobj.h" #include "mongo/db/json.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/plan_ranker.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_planner.h" diff --git a/src/mongo/db/query/plan_enumerator.cpp b/src/mongo/db/query/plan_enumerator.cpp index 326ca95c946..9d889b40987 100644 --- a/src/mongo/db/query/plan_enumerator.cpp +++ b/src/mongo/db/query/plan_enumerator.cpp @@ -34,7 +34,6 @@ #include "mongo/db/query/indexability.h" #include "mongo/db/query/index_tag.h" -#include "mongo/db/query/qlog.h" #include "mongo/util/log.h" namespace { @@ -184,7 +183,7 @@ namespace mongo { sortUsingTags(*tree); _root->resetTag(); - QLOG() << "Enumerator: memo just before moving:" << endl << dumpMemo(); + LOG(5) << "Enumerator: memo just before moving:" << endl << dumpMemo(); _done = nextMemo(memoIDForNode(_root)); return true; } @@ -1147,7 +1146,7 @@ namespace mongo { // void PlanEnumerator::tagMemo(size_t id) { - QLOG() << "Tagging memoID " << id << endl; + LOG(5) << "Tagging memoID " << id << endl; NodeAssignment* assign = _memo[id]; verify(NULL != assign); diff --git a/src/mongo/db/query/plan_ranker.cpp b/src/mongo/db/query/plan_ranker.cpp index 54075c2f16a..a735ef9d526 100644 --- a/src/mongo/db/query/plan_ranker.cpp +++ b/src/mongo/db/query/plan_ranker.cpp @@ -42,7 +42,6 @@ #include "mongo/db/query/explain.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_solution.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/server_options.h" #include "mongo/db/server_parameters.h" #include "mongo/util/log.h" @@ -95,7 +94,7 @@ namespace mongo { // Compute score for each tree. Record the best. for (size_t i = 0; i < statTrees.size(); ++i) { - QLOG() << "Scoring plan " << i << ":" << endl + LOG(5) << "Scoring plan " << i << ":" << endl << candidates[i].solution->toString() << "Stats:\n" << Explain::statsToBSON(*statTrees[i]).jsonString(Strict, true); LOG(2) << "Scoring query plan: " @@ -103,9 +102,9 @@ namespace mongo { << " planHitEOF=" << statTrees[i]->common.isEOF; double score = scoreTree(statTrees[i]); - QLOG() << "score = " << score << endl; + LOG(5) << "score = " << score << endl; if (statTrees[i]->common.isEOF) { - QLOG() << "Adding +" << eofBonus << " EOF bonus to score." << endl; + LOG(5) << "Adding +" << eofBonus << " EOF bonus to score." << endl; score += 1; } scoresAndCandidateindices.push_back(std::make_pair(score, i)); @@ -259,7 +258,6 @@ namespace mongo { << " noIxisectBonus = " << tieBreakers << ")"; std::string scoreStr = ss; - QLOG() << scoreStr << endl; LOG(2) << scoreStr; if (internalQueryForceIntersectionPlans) { @@ -267,7 +265,7 @@ namespace mongo { // The boost should be >2.001 to make absolutely sure the ixisect plan will win due // to the combination of 1) productivity, 2) eof bonus, and 3) no ixisect bonus. score += 3; - QLOG() << "Score boosted to " << score << " due to intersection forcing." << endl; + LOG(5) << "Score boosted to " << score << " due to intersection forcing." << endl; } } diff --git a/src/mongo/db/query/planner_access.cpp b/src/mongo/db/query/planner_access.cpp index e41b3559bb9..70d91540003 100644 --- a/src/mongo/db/query/planner_access.cpp +++ b/src/mongo/db/query/planner_access.cpp @@ -39,7 +39,6 @@ #include "mongo/db/query/indexability.h" #include "mongo/db/query/index_bounds_builder.h" #include "mongo/db/query/index_tag.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/query/query_planner_common.h" @@ -914,7 +913,7 @@ namespace mongo { else { // We can't use sort-based intersection, and hash-based intersection is disabled. // Clean up the index scans and bail out by returning NULL. - QLOG() << "Can't build index intersection solution: " + LOG(5) << "Can't build index intersection solution: " << "AND_SORTED is not possible and AND_HASH is disabled."; for (size_t i = 0; i < ixscanNodes.size(); i++) { diff --git a/src/mongo/db/query/planner_analysis.cpp b/src/mongo/db/query/planner_analysis.cpp index 1d8cac44090..c3d25260ab3 100644 --- a/src/mongo/db/query/planner_analysis.cpp +++ b/src/mongo/db/query/planner_analysis.cpp @@ -26,6 +26,8 @@ * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery + #include "mongo/db/query/planner_analysis.h" #include <vector> @@ -33,7 +35,7 @@ #include "mongo/db/jsobj.h" #include "mongo/db/query/query_planner_common.h" #include "mongo/db/query/query_planner.h" -#include "mongo/db/query/qlog.h" +#include "mongo/util/log.h" namespace mongo { @@ -370,7 +372,7 @@ namespace mongo { // Too many ixscans spoil the performance. if (totalNumScans > (size_t)internalQueryMaxScansToExplode) { - QLOG() << "Could expand ixscans to pull out sort order but resulting scan count" + LOG(5) << "Could expand ixscans to pull out sort order but resulting scan count" << "(" << totalNumScans << ") is too high."; return false; } @@ -430,7 +432,7 @@ namespace mongo { BSONObj reverseSort = QueryPlannerCommon::reverseSortObj(sortObj); if (sorts.end() != sorts.find(reverseSort)) { QueryPlannerCommon::reverseScans(solnRoot); - QLOG() << "Reversing ixscan to provide sort. Result: " + LOG(5) << "Reversing ixscan to provide sort. Result: " << solnRoot->toString() << endl; return solnRoot; } @@ -626,14 +628,14 @@ namespace mongo { // Project the results. if (NULL != query.getProj()) { - QLOG() << "PROJECTION: fetched status: " << solnRoot->fetched() << endl; - QLOG() << "PROJECTION: Current plan is:\n" << solnRoot->toString() << endl; + LOG(5) << "PROJECTION: fetched status: " << solnRoot->fetched() << endl; + LOG(5) << "PROJECTION: Current plan is:\n" << solnRoot->toString() << endl; ProjectionNode::ProjectionType projType = ProjectionNode::DEFAULT; BSONObj coveredKeyObj; if (query.getProj()->requiresDocument()) { - QLOG() << "PROJECTION: claims to require doc adding fetch.\n"; + LOG(5) << "PROJECTION: claims to require doc adding fetch.\n"; // If the projection requires the entire document, somebody must fetch. if (!solnRoot->fetched()) { FetchNode* fetch = new FetchNode(); @@ -645,19 +647,19 @@ namespace mongo { // The only way we're here is if it's a simple projection. That is, we can pick out // the fields we want to include and they're not dotted. So we want to execute the // projection in the fast-path simple fashion. Just don't know which fast path yet. - QLOG() << "PROJECTION: requires fields\n"; + LOG(5) << "PROJECTION: requires fields\n"; const vector<string>& fields = query.getProj()->getRequiredFields(); bool covered = true; for (size_t i = 0; i < fields.size(); ++i) { if (!solnRoot->hasField(fields[i])) { - QLOG() << "PROJECTION: not covered due to field " + LOG(5) << "PROJECTION: not covered due to field " << fields[i] << endl; covered = false; break; } } - QLOG() << "PROJECTION: is covered?: = " << covered << endl; + LOG(5) << "PROJECTION: is covered?: = " << covered << endl; // If any field is missing from the list of fields the projection wants, // a fetch is required. @@ -669,13 +671,13 @@ namespace mongo { // It's simple but we'll have the full document and we should just iterate // over that. projType = ProjectionNode::SIMPLE_DOC; - QLOG() << "PROJECTION: not covered, fetching."; + LOG(5) << "PROJECTION: not covered, fetching."; } else { if (solnRoot->fetched()) { // Fetched implies hasObj() so let's run with that. projType = ProjectionNode::SIMPLE_DOC; - QLOG() << "PROJECTION: covered via FETCH, using SIMPLE_DOC fast path"; + LOG(5) << "PROJECTION: covered via FETCH, using SIMPLE_DOC fast path"; } else { // If we're here we're not fetched so we're covered. Let's see if we can @@ -691,13 +693,13 @@ namespace mongo { projType = ProjectionNode::COVERED_ONE_INDEX; IndexScanNode* ixn = static_cast<IndexScanNode*>(leafNodes[0]); coveredKeyObj = ixn->indexKeyPattern; - QLOG() << "PROJECTION: covered via IXSCAN, using COVERED fast path"; + LOG(5) << "PROJECTION: covered via IXSCAN, using COVERED fast path"; } else if (STAGE_DISTINCT_SCAN == leafNodes[0]->getType()) { projType = ProjectionNode::COVERED_ONE_INDEX; DistinctNode* dn = static_cast<DistinctNode*>(leafNodes[0]); coveredKeyObj = dn->indexKeyPattern; - QLOG() << "PROJECTION: covered via DISTINCT, using COVERED fast path"; + LOG(5) << "PROJECTION: covered via DISTINCT, using COVERED fast path"; } } } diff --git a/src/mongo/db/query/planner_ixselect.cpp b/src/mongo/db/query/planner_ixselect.cpp index 1dc6e4b7c75..635517453db 100644 --- a/src/mongo/db/query/planner_ixselect.cpp +++ b/src/mongo/db/query/planner_ixselect.cpp @@ -39,7 +39,6 @@ #include "mongo/db/matcher/expression_text.h" #include "mongo/db/query/indexability.h" #include "mongo/db/query/index_tag.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_planner_common.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/query/qlog.cpp b/src/mongo/db/query/qlog.cpp deleted file mode 100644 index fa541f7c3ee..00000000000 --- a/src/mongo/db/query/qlog.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (C) 2013 10gen Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#include "mongo/platform/basic.h" - -#include "mongo/db/query/qlog.h" - -#include "mongo/logger/logger.h" - -namespace mongo { - - namespace { - - /** - * Updates log severity of 'verboseQueryLogComponent' in global log domain. - */ - bool setVerboseQueryLogging(bool newValue) { - bool old = logger::globalLogDomain()->shouldLog(verboseQueryLogComponent, - verboseQueryLogSeverity); - if (newValue) { - logger::globalLogDomain()->setMinimumLoggedSeverity(verboseQueryLogComponent, - verboseQueryLogSeverity); - } - else { - logger::globalLogDomain()->clearMinimumLoggedSeverity(verboseQueryLogComponent); - } - return old; - } - - } // namespace - - bool qlogOff() { - return setVerboseQueryLogging(false); - } - - bool qlogOn() { - return setVerboseQueryLogging(true); - } - -} // namespace mongo diff --git a/src/mongo/db/query/qlog.h b/src/mongo/db/query/qlog.h deleted file mode 100644 index 3050877ba2b..00000000000 --- a/src/mongo/db/query/qlog.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (C) 2013 10gen Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#pragma once - -#include "mongo/logger/log_component.h" -#include "mongo/logger/log_severity.h" -#include "mongo/logger/logger.h" -#include "mongo/logger/logstream_builder.h" -#include "mongo/util/concurrency/thread_name.h" - -namespace mongo { - - /** - * Verbose query logging is determined by the 'Query' log level in the global log domain. - * Set to verbosity 5 to enable. - * - * Command line: - * ./mongod --setParameter=logComponentVerbosity="{query: {verbosity: 5}}" - * - * Config file: - * systemLog: - * component: - * query: - * verbosity: 5 - * - * Shell: - * Enable: - * db.adminCommand({setParameter: 1, logComponentVerbosity: {query: {verbosity: 5}}}) - * Disable: - * db.adminCommand({setParameter: 1, logComponentVerbosity: {query: {verbosity: -1}}}) - */ - const logger::LogComponent verboseQueryLogComponent = logger::LogComponent::kQuery; - const logger::LogSeverity verboseQueryLogSeverity = logger::LogSeverity::Debug(5); - -// With a #define like this, we don't evaluate the costly toString()s that are QLOG'd -#define QLOG() \ - if (!(::mongo::logger::globalLogDomain())->shouldLog(::mongo::verboseQueryLogComponent, ::mongo::verboseQueryLogSeverity)) {} \ - else ::mongo::logger::LogstreamBuilder(::mongo::logger::globalLogDomain(), ::mongo::getThreadName(), ::mongo::verboseQueryLogSeverity, ::mongo::verboseQueryLogComponent) << "[QLOG] " - - bool qlogOff(); - bool qlogOn(); - -} // namespace mongo diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp index f3c1a14ce73..6e321a37487 100644 --- a/src/mongo/db/query/query_planner.cpp +++ b/src/mongo/db/query/query_planner.cpp @@ -43,7 +43,6 @@ #include "mongo/db/query/planner_analysis.h" #include "mongo/db/query/planner_ixselect.h" #include "mongo/db/query/plan_enumerator.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_planner_common.h" #include "mongo/db/query/query_solution.h" #include "mongo/util/log.h" @@ -376,7 +375,7 @@ namespace mongo { // Create a copy of the expression tree. We use cachedSoln to annotate this with indices. MatchExpression* clone = query.root()->shallowClone(); - QLOG() << "Tagging the match expression according to cache data: " << endl + LOG(5) << "Tagging the match expression according to cache data: " << endl << "Filter:" << endl << clone->toString() << "Cache data:" << endl << cacheData.toString(); @@ -387,7 +386,7 @@ namespace mongo { for (size_t i = 0; i < params.indices.size(); ++i) { const IndexEntry& ie = params.indices[i]; indexMap[ie.keyPattern] = i; - QLOG() << "Index " << i << ": " << ie.keyPattern.toString() << endl; + LOG(5) << "Index " << i << ": " << ie.keyPattern.toString() << endl; } Status s = tagAccordingToCache(clone, cacheData.tree.get(), indexMap); @@ -398,7 +397,7 @@ namespace mongo { // The planner requires a defined sort order. sortUsingTags(clone); - QLOG() << "Tagged tree:" << endl << clone->toString(); + LOG(5) << "Tagged tree:" << endl << clone->toString(); // Use the cached index assignments to build solnRoot. Takes ownership of clone. QuerySolutionNode* solnRoot = @@ -410,7 +409,7 @@ namespace mongo { params, solnRoot); if (NULL != soln) { - QLOG() << "Planner: solution constructed from the cache:\n" << soln->toString() << endl; + LOG(5) << "Planner: solution constructed from the cache:\n" << soln->toString() << endl; *out = soln; return Status::OK(); } @@ -461,14 +460,14 @@ namespace mongo { const QueryPlannerParams& params, std::vector<QuerySolution*>* out) { - QLOG() << "Beginning planning..." << endl + LOG(5) << "Beginning planning..." << endl << "=============================" << endl << "Options = " << optionString(params.options) << endl << "Canonical query:" << endl << query.toString() << "=============================" << endl; for (size_t i = 0; i < params.indices.size(); ++i) { - QLOG() << "Index " << i << " is " << params.indices[i].toString() << endl; + LOG(5) << "Index " << i << " is " << params.indices[i].toString() << endl; } bool canTableScan = !(params.options & QueryPlannerParams::NO_TABLE_SCAN); @@ -500,7 +499,7 @@ namespace mongo { // A hint overrides a $natural sort. This means that we don't force a table // scan if there is a $natural sort with a non-$natural hint. if (!naturalHint.eoo() || (!naturalSort.eoo() && hintObj.isEmpty())) { - QLOG() << "Forcing a table scan due to hinted $natural\n"; + LOG(5) << "Forcing a table scan due to hinted $natural\n"; // min/max are incompatible with $natural. if (canTableScan && query.getParsed().getMin().isEmpty() && query.getParsed().getMax().isEmpty()) { @@ -518,7 +517,7 @@ namespace mongo { QueryPlannerIXSelect::getFields(query.root(), "", &fields); for (unordered_set<string>::const_iterator it = fields.begin(); it != fields.end(); ++it) { - QLOG() << "Predicate over field '" << *it << "'" << endl; + LOG(5) << "Predicate over field '" << *it << "'" << endl; } // Filter our indices so we only look at indices that are over our predicates. @@ -557,7 +556,7 @@ namespace mongo { string hintName = firstHintElt.String(); for (size_t i = 0; i < params.indices.size(); ++i) { if (params.indices[i].name == hintName) { - QLOG() << "Hint by name specified, restricting indices to " + LOG(5) << "Hint by name specified, restricting indices to " << params.indices[i].keyPattern.toString() << endl; relevantIndices.clear(); relevantIndices.push_back(params.indices[i]); @@ -572,7 +571,7 @@ namespace mongo { if (0 == params.indices[i].keyPattern.woCompare(hintIndex)) { relevantIndices.clear(); relevantIndices.push_back(params.indices[i]); - QLOG() << "Hint specified, restricting indices to " << hintIndex.toString() + LOG(5) << "Hint specified, restricting indices to " << hintIndex.toString() << endl; hintIndexNumber = i; break; @@ -604,13 +603,13 @@ namespace mongo { // If there's an index hinted we need to be able to use it. if (!hintIndex.isEmpty()) { if (!minObj.isEmpty() && !indexCompatibleMaxMin(minObj, hintIndex)) { - QLOG() << "Minobj doesn't work with hint"; + LOG(5) << "Minobj doesn't work with hint"; return Status(ErrorCodes::BadValue, "hint provided does not work with min query"); } if (!maxObj.isEmpty() && !indexCompatibleMaxMin(maxObj, hintIndex)) { - QLOG() << "Maxobj doesn't work with hint"; + LOG(5) << "Maxobj doesn't work with hint"; return Status(ErrorCodes::BadValue, "hint provided does not work with max query"); } @@ -621,7 +620,7 @@ namespace mongo { // The min must be less than the max for the hinted index ordering. if (0 <= finishedMinObj.woCompare(finishedMaxObj, kp, false)) { - QLOG() << "Minobj/Maxobj don't work with hint"; + LOG(5) << "Minobj/Maxobj don't work with hint"; return Status(ErrorCodes::BadValue, "hint provided does not work with min/max query"); } @@ -657,13 +656,13 @@ namespace mongo { } if (idxNo == numeric_limits<size_t>::max()) { - QLOG() << "Can't find relevant index to use for max/min query"; + LOG(5) << "Can't find relevant index to use for max/min query"; // Can't find an index to use, bail out. return Status(ErrorCodes::BadValue, "unable to find relevant index for max/min query"); } - QLOG() << "Max/min query using index " << params.indices[idxNo].toString() << endl; + LOG(5) << "Max/min query using index " << params.indices[idxNo].toString() << endl; // Make our scan and output. QuerySolutionNode* solnRoot = QueryPlannerAccess::makeIndexScan(params.indices[idxNo], @@ -681,7 +680,6 @@ namespace mongo { } for (size_t i = 0; i < relevantIndices.size(); ++i) { - QLOG() << "Relevant index " << i << " is " << relevantIndices[i].toString() << endl; LOG(2) << "Relevant index " << i << " is " << relevantIndices[i].toString() << endl; } @@ -704,7 +702,7 @@ namespace mongo { } // query.root() is now annotated with RelevantTag(s). - QLOG() << "Rated tree:" << endl << query.root()->toString(); + LOG(5) << "Rated tree:" << endl << query.root()->toString(); // If there is a GEO_NEAR it must have an index it can use directly. MatchExpression* gnNode = NULL; @@ -712,13 +710,13 @@ namespace mongo { // No index for GEO_NEAR? No query. RelevantTag* tag = static_cast<RelevantTag*>(gnNode->getTag()); if (0 == tag->first.size() && 0 == tag->notFirst.size()) { - QLOG() << "Unable to find index for $geoNear query." << endl; + LOG(5) << "Unable to find index for $geoNear query." << endl; // Don't leave tags on query tree. query.root()->resetTag(); return Status(ErrorCodes::BadValue, "unable to find index for $geoNear query"); } - QLOG() << "Rated tree after geonear processing:" << query.root()->toString(); + LOG(5) << "Rated tree after geonear processing:" << query.root()->toString(); } // Likewise, if there is a TEXT it must have an index it can use directly. @@ -754,7 +752,7 @@ namespace mongo { // assigned to it. invariant(1 == tag->first.size() + tag->notFirst.size()); - QLOG() << "Rated tree after text processing:" << query.root()->toString(); + LOG(5) << "Rated tree after text processing:" << query.root()->toString(); } // If we have any relevant indices, we try to create indexed plans. @@ -770,7 +768,7 @@ namespace mongo { MatchExpression* rawTree; while (isp.getNext(&rawTree) && (out->size() < params.maxIndexedSolutions)) { - QLOG() << "About to build solntree from tagged tree:" << endl + LOG(5) << "About to build solntree from tagged tree:" << endl << rawTree->toString(); // The tagged tree produced by the plan enumerator is not guaranteed @@ -782,7 +780,7 @@ namespace mongo { PlanCacheIndexTree* cacheData; Status indexTreeStatus = cacheDataFromTaggedTree(clone.get(), relevantIndices, &cacheData); if (!indexTreeStatus.isOK()) { - QLOG() << "Query is not cachable: " << indexTreeStatus.reason() << endl; + LOG(5) << "Query is not cachable: " << indexTreeStatus.reason() << endl; } auto_ptr<PlanCacheIndexTree> autoData(cacheData); @@ -797,7 +795,7 @@ namespace mongo { params, solnRoot); if (NULL != soln) { - QLOG() << "Planner: adding solution:" << endl << soln->toString(); + LOG(5) << "Planner: adding solution:" << endl << soln->toString(); if (indexTreeStatus.isOK()) { SolutionCacheData* scd = new SolutionCacheData(); scd->tree.reset(autoData.release()); @@ -811,7 +809,7 @@ namespace mongo { // Don't leave tags on query tree. query.root()->resetTag(); - QLOG() << "Planner: outputted " << out->size() << " indexed solutions.\n"; + LOG(5) << "Planner: outputted " << out->size() << " indexed solutions.\n"; // Produce legible error message for failed OR planning with a TEXT child. // TODO: support collection scan for non-TEXT children of OR. @@ -835,7 +833,7 @@ namespace mongo { QuerySolution* soln = buildWholeIXSoln(params.indices[hintIndexNumber], query, params); verify(NULL != soln); - QLOG() << "Planner: outputting soln that uses hinted index as scan." << endl; + LOG(5) << "Planner: outputting soln that uses hinted index as scan." << endl; out->push_back(soln); } return Status::OK(); @@ -885,7 +883,7 @@ namespace mongo { const BSONObj kp = QueryPlannerAnalysis::getSortPattern(index.keyPattern); if (providesSort(query, kp)) { - QLOG() << "Planner: outputting soln that uses index to provide sort." + LOG(5) << "Planner: outputting soln that uses index to provide sort." << endl; QuerySolution* soln = buildWholeIXSoln(params.indices[i], query, params); @@ -903,7 +901,7 @@ namespace mongo { } } if (providesSort(query, QueryPlannerCommon::reverseSortObj(kp))) { - QLOG() << "Planner: outputting soln that uses (reverse) index " + LOG(5) << "Planner: outputting soln that uses (reverse) index " << "to provide sort." << endl; QuerySolution* soln = buildWholeIXSoln(params.indices[i], query, params, -1); @@ -943,7 +941,7 @@ namespace mongo { scd->solnType = SolutionCacheData::COLLSCAN_SOLN; collscan->cacheData.reset(scd); out->push_back(collscan); - QLOG() << "Planner: outputting a collscan:" << endl + LOG(5) << "Planner: outputting a collscan:" << endl << collscan->toString(); } } diff --git a/src/mongo/db/query/query_planner_common.cpp b/src/mongo/db/query/query_planner_common.cpp index c31252e3c37..e7d5e207959 100644 --- a/src/mongo/db/query/query_planner_common.cpp +++ b/src/mongo/db/query/query_planner_common.cpp @@ -26,12 +26,13 @@ * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery + #include "mongo/platform/basic.h" #include "mongo/db/query/query_planner_common.h" - -#include "mongo/db/query/qlog.h" #include "mongo/util/assert_util.h" +#include "mongo/util/log.h" namespace mongo { @@ -61,7 +62,7 @@ namespace mongo { } if (!isn->bounds.isValidFor(isn->indexKeyPattern, isn->direction)) { - QLOG() << "Invalid bounds: " << isn->bounds.toString() << std::endl; + LOG(5) << "Invalid bounds: " << isn->bounds.toString() << std::endl; invariant(0); } diff --git a/src/mongo/db/query/query_planner_test_lib.cpp b/src/mongo/db/query/query_planner_test_lib.cpp index 570d5da2e81..6384927049d 100644 --- a/src/mongo/db/query/query_planner_test_lib.cpp +++ b/src/mongo/db/query/query_planner_test_lib.cpp @@ -36,7 +36,6 @@ #include "mongo/db/jsobj.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/query/query_solution.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/db/query/query_planner_test_lib.h b/src/mongo/db/query/query_planner_test_lib.h index 8e4b9abdeab..f1d6e267512 100644 --- a/src/mongo/db/query/query_planner_test_lib.h +++ b/src/mongo/db/query/query_planner_test_lib.h @@ -34,7 +34,6 @@ #include "mongo/db/jsobj.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/query/query_solution.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/db/query/query_planner_text_test.cpp b/src/mongo/db/query/query_planner_text_test.cpp index 672af7ddc41..313f81e7cdf 100644 --- a/src/mongo/db/query/query_planner_text_test.cpp +++ b/src/mongo/db/query/query_planner_text_test.cpp @@ -37,7 +37,6 @@ #include "mongo/db/jsobj.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/query/query_solution.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/dbtests/plan_ranking.cpp b/src/mongo/dbtests/plan_ranking.cpp index afef3d54a82..a9be990268d 100644 --- a/src/mongo/dbtests/plan_ranking.cpp +++ b/src/mongo/dbtests/plan_ranking.cpp @@ -42,7 +42,6 @@ #include "mongo/db/json.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/query/get_executor.h" -#include "mongo/db/query/qlog.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/query/query_planner_test_lib.h" |