/*@ @param opstr: c userCreateNS i insert n no-op / keepalive d delete / remove u update */ void logOp(OperationContext* txn, const char* opstr, const char* ns, const BSONObj& obj, BSONObj* patt, bool* b, bool fromMigrate) { try { if ( getGlobalReplicationCoordinator()->isReplEnabled() ) { _logOp(txn, opstr, ns, 0, obj, patt, b, fromMigrate); } logOpForSharding(txn, opstr, ns, obj, patt, fromMigrate); logOpForDbHash(ns); getGlobalAuthorizationManager()->logOp(opstr, ns, obj, patt, b); if ( strstr( ns, ".system.js" ) ) { Scope::storedFuncMod(); // this is terrible } } catch (const DBException& ex) { severe() << "Fatal DBException in logOp(): " << ex.toString(); std::terminate(); } catch (const std::exception& ex) { severe() << "Fatal std::exception in logOp(): " << ex.what(); std::terminate(); } catch (...) { severe() << "Fatal error in logOp()"; std::terminate(); } }
/*@ @param opstr: c userCreateNS i insert n no-op / keepalive d delete / remove u update */ void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt, bool *b) { if ( replSettings.master ) { _logOp(opstr, ns, 0, obj, patt, b); } logOpForSharding( opstr , ns , obj , patt ); }
void OpObserver::onUpdate(OperationContext* txn, oplogUpdateEntryArgs args) { repl::logOp(txn, "u", args.ns.c_str(), args.update, &args.criteria, args.fromMigrate); getGlobalAuthorizationManager()->logOp(txn, "u", args.ns.c_str(), args.update, &args.criteria); logOpForSharding(txn, "u", args.ns.c_str(), args.update, &args.criteria, args.fromMigrate); logOpForDbHash(txn, args.ns.c_str()); if (strstr(args.ns.c_str(), ".system.js")) { Scope::storedFuncMod(txn); } }
void OpObserver::onCreateIndex(OperationContext* txn, const std::string& ns, BSONObj indexDoc, bool fromMigrate) { repl::logOp(txn, "i", ns.c_str(), indexDoc, nullptr, fromMigrate); getGlobalAuthorizationManager()->logOp(txn, "i", ns.c_str(), indexDoc, nullptr); logOpForSharding(txn, "i", ns.c_str(), indexDoc, nullptr, fromMigrate); logOpForDbHash(txn, ns.c_str()); }
/*@ @param opstr: c userCreateNS i insert n no-op / keepalive d delete / remove u update */ void logOp(const char* opstr, const char* ns, const BSONObj& obj, BSONObj* patt, bool* b, bool fromMigrate, const BSONObj* fullObj) { if ( replSettings.master ) { _logOp(opstr, ns, 0, obj, patt, b, fromMigrate); } logOpForSharding(opstr, ns, obj, patt, fullObj, fromMigrate); }
void OpObserver::onDelete(OperationContext* txn, const std::string& ns, const BSONObj& idDoc, bool fromMigrate) { repl::logOp(txn, "d", ns.c_str(), idDoc, nullptr, fromMigrate); getGlobalAuthorizationManager()->logOp(txn, "d", ns.c_str(), idDoc, nullptr); logOpForSharding(txn, "d", ns.c_str(), idDoc, nullptr, fromMigrate); logOpForDbHash(txn, ns.c_str()); if (strstr(ns.c_str(), ".system.js")) { Scope::storedFuncMod(txn); } }
void OpObserver::onInsert(OperationContext* txn, const NamespaceString& ns, BSONObj doc, bool fromMigrate) { repl::logOp(txn, "i", ns.ns().c_str(), doc, nullptr, fromMigrate); getGlobalAuthorizationManager()->logOp(txn, "i", ns.ns().c_str(), doc, nullptr); logOpForSharding(txn, "i", ns.ns().c_str(), doc, nullptr, fromMigrate); logOpForDbHash(txn, ns.ns().c_str()); if (strstr(ns.ns().c_str(), ".system.js")) { Scope::storedFuncMod(txn); } }
/*@ @param opstr: c userCreateNS i insert n no-op / keepalive d delete / remove u update */ void logOp(OperationContext* txn, const char* opstr, const char* ns, const BSONObj& obj, BSONObj* patt, bool* b, bool fromMigrate) { try { // TODO SERVER-15192 remove this once all listeners are rollback-safe. class RollbackPreventer : public RecoveryUnit::Change { virtual void commit() {} virtual void rollback() { severe() << "Rollback of logOp not currently allowed (SERVER-15192)"; fassertFailed(18805); } }; txn->recoveryUnit()->registerChange(new RollbackPreventer()); if ( getGlobalReplicationCoordinator()->isReplEnabled() ) { _logOp(txn, opstr, ns, 0, obj, patt, b, fromMigrate); } logOpForSharding(txn, opstr, ns, obj, patt, fromMigrate); logOpForDbHash(ns); getGlobalAuthorizationManager()->logOp(opstr, ns, obj, patt, b); if ( strstr( ns, ".system.js" ) ) { Scope::storedFuncMod(); // this is terrible } } catch (const DBException& ex) { severe() << "Fatal DBException in logOp(): " << ex.toString(); std::terminate(); } catch (const std::exception& ex) { severe() << "Fatal std::exception in logOp(): " << ex.what(); std::terminate(); } catch (...) { severe() << "Fatal error in logOp()"; std::terminate(); } }
/*@ @param opstr: c userCreateNS i insert n no-op / keepalive d delete / remove u update */ void logOp(OperationContext* txn, const char* opstr, const char* ns, const BSONObj& obj, BSONObj* patt, bool* b, bool fromMigrate) { if ( replSettings.master ) { _logOp(txn, opstr, ns, 0, obj, patt, b, fromMigrate); } logOpForSharding(txn, opstr, ns, obj, patt, fromMigrate); logOpForDbHash(ns); getGlobalAuthorizationManager()->logOp(opstr, ns, obj, patt, b); if ( strstr( ns, ".system.js" ) ) { Scope::storedFuncMod(); // this is terrible } }