int DictionaryDatabase::lookupNameFromID(OperationContext &context, const NameID &id, Name &name) const { int err = 0; nameId_t raw = id.raw() - 1; // id space is 1-based, not 0 if (id == nidName_) { name = Name::dbxml_colon_name; return 0; } else if (id == nidRoot_) { name = Name::dbxml_colon_root; return 0; } if ((raw < DICTIONARY_RESERVE_SIZE) && usePreloads_) { name = preloadNames[raw]; } else { err = lookupFromID(context, context.data(), id); if (err == 0) { name.setThisFromDbt(context.data()); } else { name.reset(); } } return err; }
void StructuralStatsDatabase::display(OperationContext &context, ostream &out, const DictionaryDatabase *ddb) const { Cursor myCursor(const_cast<DbWrapper&>(db_), getTxn(context), CURSOR_WRITE, 0); if(myCursor.error() != 0) throw XmlException(myCursor.error()); NameID id1; NameID id2; StructuralStats stats; int err = 0; while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) { id1.reset(); id2.reset(); unmarshalKey(context.key(), id1, id2); stats.reset(); stats.unmarshal(context.data()); if(ddb) out << ddb->lookupName(context, id1); else out << id1; if(id2 != 0) { if(ddb) out << " -> " << ddb->lookupName(context, id2); else out << " -> " << id2; } out << ": "; stats.display(out); out << endl; } }
OperationContext ClientCIMOMHandleRep::getResponseContext() { OperationContext ctx; Thread* curThrd = Thread::getCurrent(); if (curThrd == NULL) { ctx.insert(ContentLanguageListContainer(ContentLanguageList())); } else { ContentLanguageList* contentLangs = (ContentLanguageList*) curThrd->reference_tsd(TSD_CIMOM_HANDLE_CONTENT_LANGUAGES); curThrd->dereference_tsd(); if (contentLangs == NULL) { ctx.insert(ContentLanguageListContainer(ContentLanguageList())); } else { ctx.insert(ContentLanguageListContainer(*contentLangs)); // delete the old tsd to free the memory curThrd->delete_tsd(TSD_CIMOM_HANDLE_CONTENT_LANGUAGES); } } return ctx; }
SessionKiller::Result killSessionsLocalKillOps(OperationContext* opCtx, const SessionKiller::Matcher& matcher) { for (ServiceContext::LockedClientsCursor cursor(opCtx->getClient()->getServiceContext()); Client* client = cursor.next();) { invariant(client); stdx::unique_lock<Client> lk(*client); OperationContext* opCtxToKill = client->getOperationContext(); if (opCtxToKill) { const auto& lsid = opCtxToKill->getLogicalSessionId(); if (lsid) { if (const KillAllSessionsByPattern* pattern = matcher.match(*lsid)) { ScopedKillAllSessionsByPatternImpersonator impersonator(opCtx, *pattern); log() << "killing op: " << opCtxToKill->getOpID() << " as part of killing session: " << lsid->toBSON(); opCtx->getServiceContext()->killOperation(opCtxToKill); } } } } return {std::vector<HostAndPort>{}}; }
int DocumentDatabase::getMetaData(OperationContext &context, DictionaryDatabase *dictionary, const Name &name, const DocID &did, XmlValue::Type &type, DbXmlDbt *metadata, u_int32_t flags) const { NameID nid; int err = dictionary->lookupIDFromName(context, name, nid, /*define=*/false); if(err == 0) { Cursor cursor(const_cast<SecondaryDatabase&>(secondary_), context.txn(), CURSOR_READ, "DocumentMetaData", flags); u_int32_t origFlags = DB_CURSOR_GET_MASK(const_cast<SecondaryDatabase&>(secondary_),flags); MetaDatum::setKeyDbt(did, nid, XmlValue::NONE, context.key()); DbtIn none; none.set_flags(DB_DBT_PARTIAL); // Don't pull back the data. err = cursor.get(context.key(), none, (flags | DB_SET_RANGE) & ~DB_RMW); if (err == 0) { DocID db_did; NameID db_nid; MetaDatum::decodeKeyDbt(context.key(), db_did, db_nid, type); if(db_did == did && db_nid == nid) { err = cursor.get(context.key(), *metadata, origFlags|DB_CURRENT); } else { return DB_NOTFOUND; } } } return err; }
int StructuralStatsDatabase::getStats(OperationContext &context, StructuralStats &stats) const { Cursor myCursor(const_cast<DbWrapper&>(db_), getTxn(context), CURSOR_READ, 0); if(myCursor.error() != 0) return myCursor.error(); StructuralStats current; // Loop over every node and every node's descendant information int err; while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) { current.reset(); current.unmarshal(context.data()); stats.add(current); } if(err != DB_NOTFOUND && err != 0) return err; if(stats.sumSize_ == 0 && stats.numberOfNodes_ != 0) { // Fill in an estimate for the missing size values that you get with DLS stats.sumSize_ = NODE_SIZE * stats.numberOfNodes_; stats.sumChildSize_ = NODE_SIZE * stats.sumNumberOfChildren_; stats.sumDescendantSize_ = NODE_SIZE * stats.sumNumberOfDescendants_; } return 0; }
void DictionaryDatabase::display(OperationContext &context, ostream &out) const { { Cursor myCursor(const_cast<PrimaryDatabase&>(*primary_.get()), getTxn(context), CURSOR_READ, 0); if(myCursor.error() != 0) throw XmlException(myCursor.error()); int err = 0; NameID id; while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) { id.setThisFromDbtAsId(context.key()); Buffer val(context.data().data, context.data().size, true); out << id << " -> " << val.asString(true) << endl; } } { Cursor myCursor(const_cast<SecondaryDatabase&>(*secondary_.get()), getTxn(context), CURSOR_READ, 0); if(myCursor.error() != 0) throw XmlException(myCursor.error()); int err = 0; NameID id; while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) { Buffer val(context.key().data, context.key().size, true); id.setThisFromDbt(context.data()); out << val.asString(true) << " -> " << id << endl; } } }
int StructuralStatsDatabase::subtractStats(OperationContext &context, const NameID &id1, const NameID &id2, const StructuralStats &stats) { DBXML_ASSERT(id1 != 0 || id2 == 0); Cursor myCursor(const_cast<DbWrapper&>(db_), getTxn(context), CURSOR_WRITE, 0); if(myCursor.error() != 0) return myCursor.error(); marshalKey(id1, id2, context.key()); int err = myCursor.get(context.key(), context.data(), DB_SET); if(err != DB_NOTFOUND && err != 0) return err; StructuralStats current; if(err == DB_NOTFOUND) { current.subtract(stats); current.marshal(context.data(), id2 == 0); err = myCursor.put(context.key(), context.data(), DB_KEYLAST); } else { current.unmarshal(context.data()); current.subtract(stats); current.marshal(context.data(), id2 == 0); err = myCursor.put(context.key(), context.data(), DB_CURRENT); } return err; }
int DocumentDatabase::addMetaData(OperationContext &oc, DictionaryDatabase *dictionary, Document &document) { int err = 0; MetaData::const_iterator end = document.metaDataEnd(); MetaData::const_iterator i; for (i = document.metaDataBegin(); err == 0 && i != end; ++i) { NameID nid; err = dictionary->lookupIDFromName(oc, (*i)->getName(), nid, /*define=*/true); if(err == 0) { DbtIn value; MetaDatum::setKeyDbt(document.getID(), nid, (*i)->getType(), oc.key()); (*i)->setValueDbtFromThis(value); // could throw on error err = secondary_.put(oc.txn(), &oc.key(), &value, 0); } } if(err == 0) for(i = document.metaDataBegin(); i != end; ++i) (*i)->setModified(false); return err; }
int SyntaxDatabase::removeIndexEntries(OperationContext &context, DbWrapper &db, void *buf, u_int32_t bufsize) { unsigned char keybuf[10]; // assert bufsize < 10; memcpy(keybuf, buf, bufsize); DbtIn key(keybuf, bufsize); key.ulen = (bufsize); key.dlen = (bufsize); key.doff = (0); key.set_flags(DB_DBT_PARTIAL); DbtIn data(0,0); data.set_flags(DB_DBT_PARTIAL); data.dlen = (0); u_int32_t flags = (context.txn() ? DB_RMW : 0); int err; // remove from index database Cursor cursor(db, context.txn(), CURSOR_WRITE); err = cursor.get(key, data, flags|DB_SET_RANGE); while ((err == 0) && (memcmp(key.data, buf, bufsize) == 0)) { cursor.del(0); err = cursor.get(key, data, flags|DB_NEXT); if (err == DB_NOTFOUND) break; } if (err == DB_NOTFOUND) err = 0; return err; }
bool PlanYieldPolicy::yield(RecordFetcher* fetcher) { invariant(_planYielding); OperationContext* opCtx = _planYielding->getOpCtx(); invariant(opCtx); // All YIELD_AUTO plans will get here eventually when the elapsed tracker triggers that it's // time to yield. Whether or not we will actually yield (doc-level locking systems won't), // we need to check if this operation has been interrupted. Throws if the interrupt flag is // set. opCtx->checkForInterrupt(); if (supportsDocLocking()) { // Doc-level locking is supported, so no need to release locks. return true; } // No need to yield if the collection is NULL. if (NULL == _planYielding->collection()) { return true; } _planYielding->saveState(); // Release and reacquire locks. QueryYield::yieldAllLocks(opCtx, fetcher); _elapsedTracker.resetLastTime(); return _planYielding->restoreState(opCtx); }
int StructuralStatsDatabase::addStats(OperationContext &context, const StructuralStatsWriteCache &cache) { Cursor myCursor(db_, getTxn(context), CURSOR_WRITE, 0); if(myCursor.error() != 0) return myCursor.error(); int err = 0; StructuralStats current; StructuralStatsWriteCache::Map::const_iterator it = cache.cache_.begin(); for(; err == 0 && it != cache.cache_.end(); ++it) { StructuralStatsWriteCache::InnerMap::const_iterator it2 = it->second.begin(); for(; it2 != it->second.end(); ++it2) { marshalKey(it->first, it2->first, context.key()); err = myCursor.get(context.key(), context.data(), DB_SET); if(err == DB_NOTFOUND) { it2->second.marshal(context.data(), it2->first == 0); err = myCursor.put(context.key(), context.data(), DB_KEYLAST); } else if(err == 0) { current.unmarshal(context.data()); current.add(it2->second); current.marshal(context.data(), it2->first == 0); err = myCursor.put(context.key(), context.data(), DB_CURRENT); } else break; } } if(err != DB_NOTFOUND) return err; return 0; }
int DocumentDatabase::reindex(const Document &document, OperationContext &oc, bool updateStats, bool forDelete) { XmlManager mgr = document.getManager(); ScopedContainer sc(mgr, document.getContainerID(), true); Container *cont = sc.getContainer(); UpdateContext uc(mgr); Indexer &indexer = uc.getIndexer(); IndexSpecification is; cont->getIndexSpecification(oc.txn(), is); indexer.resetContext(cont, &oc); KeyStash &ks = uc.getKeyStash(); ks.reset(); if (forDelete) is.set(Index::INDEXER_DELETE); // Index the document indexer.indexMetaData(is, document, ks, /*checkModified*/false); ScopedPtr<NsPushEventSource> source(document. getContentAsEventSource(oc.txn(), /*needsValidation*/false, indexer.getContainer()->nodesIndexed())); if (source.get()) { indexer.initIndexContent(is, document.getID(), source.get(), ks, updateStats, false, /*isDelete*/forDelete); source.get()->start(); } ks.updateIndex(oc, cont); return 0; }
void MobileSessionPool::shutDown() { stdx::unique_lock<stdx::mutex> lk(_mutex); _shuttingDown = true; // Retrieve the operation context from the thread's client if the client exists. if (haveClient()) { OperationContext* opCtx = cc().getOperationContext(); // Locks if the operation context still exists. if (opCtx) { opCtx->waitForConditionOrInterrupt( _releasedSessionNotifier, lk, [&] { return _sessions.size() == _curPoolSize; }); } } else { _releasedSessionNotifier.wait(lk, [&] { return _sessions.size() == _curPoolSize; }); } // Retry all the drops that have been queued on failure. // Create a new sqlite session to do so, all other sessions might have been closed already. if (!failedDropsQueue.isEmpty()) { sqlite3* session; int status = sqlite3_open(_path.c_str(), &session); embedded::checkStatus(status, SQLITE_OK, "sqlite3_open"); std::unique_ptr<MobileSession> mobSession = stdx::make_unique<MobileSession>(session, this); LOG(MOBILE_LOG_LEVEL_LOW) << "MobileSE: Executing queued drops at shutdown"; failedDropsQueue.execAndDequeueAllOps(mobSession.get()); sqlite3_close(session); } for (auto&& session : _sessions) { sqlite3_close(session); } }
void OperationContextTestCases::testStringData() { OperationContext context; context.setStringData("key", "value"); String val; unitAssertNoThrow(val = context.getStringData("key")); unitAssert(val == "value"); }
// We assume that key has the correct endianness. int IndexDatabase::getIndexEntry(OperationContext &context, const DbXmlDbt &key, IndexEntry &ie) const { u_int32_t flags = (context.txn()) ? DB_READ_COMMITTED : 0; int err = get(context.txn(), &(const_cast<DbXmlDbt&>(key)), &context.data(), flags); if(err == 0) { ie.setThisFromDbt(context.data()); } return err; }
svn_error_t * OperationContext::clientName(void *baton, const char **name, apr_pool_t *pool) { OperationContext *that = (OperationContext *) baton; *name = that->getClientName(); return SVN_NO_ERROR; }
void RT_IndicationProvider::_checkOperationContext(const OperationContext& context, const String & funcName) { // // Test the filter query container // SubscriptionFilterQueryContainer qContainer = context.get(SubscriptionFilterQueryContainer::NAME); if (qContainer.getFilterQuery() == String::EMPTY) { PEGASUS_STD(cout) << funcName << "- empty filter query" << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- empty filter query"); } if (qContainer.getQueryLanguage() == String::EMPTY) { PEGASUS_STD(cout) << funcName << "- empty filter query lang" << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- empty filter query lang"); } CIMNamespaceName tst("root/SampleProvider"); if (!qContainer.getSourceNameSpace().equal(tst)) { PEGASUS_STD(cout) << funcName << "- incorrect source namespace" << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- incorrect source namespace"); } try { // // Try to parse the filter query from the filter query container // CIMOMHandleQueryContext ctx(qContainer.getSourceNameSpace(), _cimom); QueryExpression qe(qContainer.getQueryLanguage(), qContainer.getFilterQuery(), ctx); // Exercise the QueryExpression...this will cause repository access through // the CIMOMHandleQueryContext. qe.validate(); } catch (Exception & e) { PEGASUS_STD(cout) << funcName << "- parse error: " << e.getMessage() << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- parse error: " + e.getMessage()); } // // Test the filter condition container. // Note: since this only contains the WHERE clause, the condition could be empty (and will // be for some testcases) // SubscriptionFilterConditionContainer cContainer = context.get(SubscriptionFilterConditionContainer::NAME); if (cContainer.getQueryLanguage() == String::EMPTY) { PEGASUS_STD(cout) << funcName << "- empty filter condition lang" << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- empty filter condition lang"); } }
int PrimaryDatabase::appendPrimary(OperationContext &context, NameID &id, const DbXmlDbt &data, u_int32_t flags) { int err = put(context.txn(), &context.key(), &(const_cast<DbXmlDbt&>(data)), flags | DB_APPEND); if (err == 0) id.setThisFromDbtAsId(context.key()); return err; }
Status PlanYieldPolicy::yield(stdx::function<void()> beforeYieldingFn, stdx::function<void()> whileYieldingFn) { invariant(_planYielding); invariant(canAutoYield()); // After we finish yielding (or in any early return), call resetTimer() to prevent yielding // again right away. We delay the resetTimer() call so that the clock doesn't start ticking // until after we return from the yield. ON_BLOCK_EXIT([this]() { resetTimer(); }); _forceYield = false; OperationContext* opCtx = _planYielding->getOpCtx(); invariant(opCtx); invariant(!opCtx->lockState()->inAWriteUnitOfWork()); // Can't use writeConflictRetry since we need to call saveState before reseting the transaction. for (int attempt = 1; true; attempt++) { try { // All YIELD_AUTO plans will get here eventually when the elapsed tracker triggers // that it's time to yield. Whether or not we will actually yield, we need to check // if this operation has been interrupted. if (_policy == PlanExecutor::YIELD_AUTO) { MONGO_FAIL_POINT_PAUSE_WHILE_SET(setCheckForInterruptHang); auto interruptStatus = opCtx->checkForInterruptNoAssert(); if (!interruptStatus.isOK()) { return interruptStatus; } } try { _planYielding->saveState(); } catch (const WriteConflictException&) { invariant(!"WriteConflictException not allowed in saveState"); } if (_policy == PlanExecutor::WRITE_CONFLICT_RETRY_ONLY) { // Just reset the snapshot. Leave all LockManager locks alone. opCtx->recoveryUnit()->abandonSnapshot(); } else { // Release and reacquire locks. if (beforeYieldingFn) beforeYieldingFn(); QueryYield::yieldAllLocks(opCtx, whileYieldingFn, _planYielding->nss()); } return _planYielding->restoreStateWithoutRetrying(); } catch (const WriteConflictException&) { CurOp::get(opCtx)->debug().writeConflicts++; WriteConflictException::logAndBackoff( attempt, "plan execution restoreState", _planYielding->nss().ns()); // retry } } }
int DocumentDatabase::getAllMetaData(OperationContext &context, DictionaryDatabase *dictionary, Document *document, u_int32_t flags) const { int err = 0; u_int32_t orig_flags = flags; const DocID &did = document->getID(); // // Read each of the meta-data items from the document secondary // database. Content is no longer considered metadata // Cursor cursor(const_cast<SecondaryDatabase&>(secondary_), context.txn(), CURSOR_READ, "DocumentMetaData", flags); orig_flags = flags = DB_CURSOR_GET_MASK(const_cast<SecondaryDatabase&>(secondary_),flags); flags |= DB_SET_RANGE; bool done = false; while (!done) { did.setDbtFromThis(context.key()); DbtIn none; none.set_flags(DB_DBT_PARTIAL); // Don't pull back the data. // if DB_RMW set, don't get locks on this get, wait for a match err = cursor.get(context.key(), none, flags & (~DB_RMW)); if (err == 0) { DocID db_did; NameID db_nid; XmlValue::Type type; MetaDatum::decodeKeyDbt(context.key(), db_did, db_nid, type); if (did == db_did) { Name name; err = dictionary->lookupNameFromID(context, db_nid, name); if(err == 0 && !document->containsMetaData(name)) { DbtOut *data = new DbtOut(); err = cursor.get(context.key(), *data, DB_CURRENT); if(err == 0) document->setMetaData( name, type, &data, /*modified*/false); delete data; // If not consumed by setThis.. } flags = orig_flags | DB_NEXT; } else { err = 0; done = true; } } else if (err == DB_NOTFOUND) { err = 0; done = true; } else { done = true; } } return err; }
void EnableIndicationsResponseHandler::deliver(const CIMIndication & cimIndication) { OperationContext context; Array<CIMObjectPath> subscriptionInstanceNames; context.insert(SubscriptionInstanceNamesContainer(subscriptionInstanceNames)); deliver(context, cimIndication); }
void NsUpgradeReader::initDocInfo() { // read doc node // read namespace info OperationContext oc; oc.set(NULL); const char metadataId[] = { NS_PROTOCOL_VERSION_COMPAT, NS_METADATA_ID, 0 }; DbtOut data((void *)metadataId, strlen(metadataId) + 1); // reproduce old NsDocumentDatabase::getNodeRecord(), but // cannot deadlock -- no transaction DBXML_ASSERT(!oc.txn()); id_.setDbtFromThis(oc.key()); int ret = db_.get(oc.txn(), &oc.key(), &data, DB_GET_BOTH); uint32_t flags = 0; if (ret == 0) { const xmlbyte_t *ptr = (const xmlbyte_t *) data.data; ptr += 3; // past version and id size_t len; ptr += NsFormat::unmarshalInt(ptr, &flags); if (flags & NSDOC_HASDECL) { ptr += NsFormat::unmarshalInt(ptr, &xmlDecl_); DBXML_ASSERT(xmlDecl_ == 0 || xmlDecl_ == 1); } if (flags & NSDOC_HASENCODE) { DBXML_ASSERT(!encStr_); encStr_ = NsUtil::nsStringDup(ptr, &len); ptr += len; } if (flags & NSDOC_HASSNIFF) { sniffStr_ = NsUtil::nsStringDup(ptr, &len); ptr += len; } if (flags & NSDOC_STANDYES) standStr_ = _standYes; if (flags & NSDOC_STANDNO) standStr_ = _standNo; } if (flags & NSDOC_NAMESPACE) { nsInfo_ = new NsNamespaceInfo(); if (!nsInfo_) NsUtil::nsThrowException(XmlException::NO_MEMORY_ERROR, "new failed to allocate memory", __FILE__, __LINE__); nsInfo_->initialize(); const char namespaceId[] = { NS_PROTOCOL_VERSION_COMPAT, NS_NAMESPACE_ID, 0 }; DbtOut ndata((void *)namespaceId, strlen(namespaceId) + 1); id_.setDbtFromThis(oc.key()); ret = db_.get(oc.txn(), &oc.key(), &ndata, DB_GET_BOTH); if (ret == 0) { nsInfo_->load((const char*) ((const char *)ndata.data)+3); } } }
svn_error_t * OperationContext::checkCancel(void *cancelBaton) { OperationContext *that = static_cast<OperationContext *>(cancelBaton); if (that->isCancelledOperation()) return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Operation cancelled")); else if (JNIUtil::isJavaExceptionThrown()) return svn_error_create(SVN_ERR_CANCELLED, JNIUtil::wrapJavaException(), _("Operation cancelled")); else return SVN_NO_ERROR; }
bool ServiceContextMongoD::_killOperationsAssociatedWithClientAndOpId_inlock(Client* client, unsigned int opId) { OperationContext* opCtx = client->getOperationContext(); if (!opCtx) { return false; } if (opCtx->getOpID() != opId) { return false; } _killOperation_inlock(opCtx); return true; }
Status PlanYieldPolicy::yieldOrInterrupt(stdx::function<void()> beforeYieldingFn, stdx::function<void()> whileYieldingFn) { if (_policy == PlanExecutor::INTERRUPT_ONLY) { ON_BLOCK_EXIT([this]() { resetTimer(); }); OperationContext* opCtx = _planYielding->getOpCtx(); invariant(opCtx); MONGO_FAIL_POINT_PAUSE_WHILE_SET(setCheckForInterruptHang); return opCtx->checkForInterruptNoAssert(); } return yield(beforeYieldingFn, whileYieldingFn); }
bool PlanYieldPolicy::yield(RecordFetcher* fetcher) { invariant(_planYielding); invariant(allowedToYield()); _forceYield = false; OperationContext* opCtx = _planYielding->getOpCtx(); invariant(opCtx); invariant(!opCtx->lockState()->inAWriteUnitOfWork()); // Can't use MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN/END since we need to call saveState // before reseting the transaction. for (int attempt = 1; true; attempt++) { try { // All YIELD_AUTO plans will get here eventually when the elapsed tracker triggers // that it's time to yield. Whether or not we will actually yield, we need to check // if this operation has been interrupted. Throws if the interrupt flag is set. if (_policy == PlanExecutor::YIELD_AUTO) { opCtx->checkForInterrupt(); } // No need to yield if the collection is NULL. if (NULL == _planYielding->collection()) { return true; } try { _planYielding->saveState(); } catch (const WriteConflictException& wce) { invariant(!"WriteConflictException not allowed in saveState"); } if (_policy == PlanExecutor::WRITE_CONFLICT_RETRY_ONLY) { // Just reset the snapshot. Leave all LockManager locks alone. opCtx->recoveryUnit()->commitAndRestart(); } else { // Release and reacquire locks. QueryYield::yieldAllLocks(opCtx, fetcher); } return _planYielding->restoreStateWithoutRetrying(opCtx); } catch (const WriteConflictException& wce) { opCtx->getCurOp()->debug().writeConflicts++; WriteConflictException::logAndBackoff(attempt, "plan execution restoreState", _planYielding->collection()->ns().ns()); // retry } } }
bool ServiceContextMongoD::killOperation(unsigned int opId) { for (LockedClientsCursor cursor(this); Client* client = cursor.next();) { stdx::lock_guard<Client> lk(*client); OperationContext* opCtx = client->getOperationContext(); if (opCtx && opCtx->getOpID() == opId) { _killOperation_inlock(opCtx, ErrorCodes::Interrupted); return true; } } return false; }
void AuthorizerManager::turnOff( OperationContext& context) { context.setStringData(DISABLED_KEY, "1"); }
int DictionaryDatabase::lookupStringNameFromID( OperationContext &context, const NameID &id, const char **name) const { int err = 0; nameId_t raw = id.raw() - 1; // id space is 1-based, not 0 if ((raw < DICTIONARY_RESERVE_SIZE) && usePreloads_) { *name = preloadNames[raw]; } else { err = lookupFromID(context, context.data(), id); if (err == 0) *name = (const char *)context.data().data; } return err; }