-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.6.5, 4.0.0-rc4
-
Component/s: Internal Client, Shell
-
None
-
Fully Compatible
-
ALL
-
v4.0, v3.6
-
-
Sharding 2018-07-16, Sharding 2018-07-30, Sharding 2018-08-13
-
(copied to CRM)
-
0
Update: to solve a greater issue uncovered by this ticket, we will prevent any operation session info from being set inside a direct client.
Since eval reuses its operation context for the commands it runs, if an eval is run inside a session and an inner command contains a different lsid, this invariant can be hit when parsing the inner command here, since the outer eval will have already placed the id of its session on the operation context.
This doesn't fail for other commands as far as I can tell, only count. It may have something to do with the special handling of count inside dbdirectclient.
Example stacktrace:
2018-05-22T18:16:48.754-0400 F - [js] Invariant failure !_lsid src/mongo/db/operation_context.cpp 368 2018-05-22T18:16:48.754-0400 F - [js] ***aborting after invariant() failure 2018-05-22T18:16:48.865-0400 F - [js] Got signal: 6 (Aborted). 0x5622739eb968 0x5622739ea92d 0x5622739ead9a 0x7f4560cac890 0x7f45608e7e97 0x7f45608e9801 0x5622739def8c 0x562271a14093 0x56227391fed1 0x56227314a80b 0x562271a7918c 0x562271a7bd5e 0x562271a7c590 0x562271a7e821 0x562271a658e4 0x562273004d67 0x562273004e59 0x5622732291df 0x56227322944a 0x562273229797 0x5622723812b0 0x56227238e1ae 0x562272a6a2c6 0x5622728c2d2f 0x562272a6a2c6 0x562272a7b5cd 0x562272a69ee5 0x562272a6a3cf 0x562272a6a749 0x56227286e8e5 0x562272357fdd 0x56227235cd28 0x5622723a8f63 0x5622723ae918 0x562271a7181e 0x5622723a9767 0x5622723a5648 0x5622723a7826 0x5622723a7730 0x5622723a76c0 0x562273b851d0 0x7f4560ca16db 0x7f45609ca88f ----- BEGIN BACKTRACE ----- {"backtrace":[{"b":"56226F1E9000","o":"4802968","s":"mongo::printStackTrace(std::ostream&)"},{"b":"56226F1E9000","o":"480192D"},{"b":"56226F1E9000","o":"4801D9A"},{"b":"7F4560C9A000","o":"12890"},{"b":"7F45608A9000","o":"3EE97","s":"gsignal"},{"b":"7F45608A9000","o":"40801","s":"abort"},{"b":"56226F1E9000","o":"47F5F8C","s":"mongo::invariantFailedWithMsg(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, unsigned int)"},{"b":"56226F1E9000","o":"282B093","s":"void mongo::invariantWithLocation<bool>(bool const&, char const*, char const*, unsigned int)"},{"b":"56226F1E9000","o":"4736ED1","s":"mongo::OperationContext::setLogicalSessionId(mongo::LogicalSessionId)"},{"b":"56226F1E9000","o":"3F6180B","s":"mongo::initializeOperationSessionInfo(mongo::OperationContext*, mongo::BSONObj const&, bool, bool, bool)"},{"b":"56226F1E9000","o":"289018C"},{"b":"56226F1E9000","o":"2892D5E"},{"b":"56226F1E9000","o":"2893590"},{"b":"56226F1E9000","o":"2895821","s":"mongo::ServiceEntryPointCommon::handleRequest(mongo::OperationContext*, mongo::Message const&, mongo::ServiceEntryPointCommon::Hooks const&)"},{"b":"56226F1E9000","o":"287C8E4","s":"mongo::ServiceEntryPointMongod::handleRequest(mongo::OperationContext*, mongo::Message const&)"},{"b":"56226F1E9000","o":"3E1BD67"},{"b":"56226F1E9000","o":"3E1BE59","s":"mongo::DBDirectClient::call(mongo::Message&, mongo::Message&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)"},{"b":"56226F1E9000","o":"40401DF","s":"mongo::DBClientBase::runCommandWithTarget(mongo::OpMsgRequest)"},{"b":"56226F1E9000","o":"404044A","s":"mongo::DBClientBase::runCommandWithTarget(mongo::OpMsgRequest, std::shared_ptr<mongo::DBClientBase>)"},{"b":"56226F1E9000","o":"4040797","s":"mongo::DBClientBase::runCommandWithTarget(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mongo::BSONObj, mongo::BSONObj&, std::shared_ptr<mongo::DBClientBase>, int)"},{"b":"56226F1E9000","o":"31982B0","s":"mongo::mozjs::MongoBase::Functions::runCommand::call(JSContext*, JS::CallArgs)"},{"b":"56226F1E9000","o":"31A51AE","s":"bool mongo::mozjs::smUtils::wrapConstrainedMethod<mongo::mozjs::MongoBase::Functions::runCommand, true, mongo::mozjs::MongoLocalInfo, mongo::mozjs::MongoExternalInfo>(JSContext*, unsigned int, JS::Value*)"},{"b":"56226F1E9000","o":"38812C6","s":"js::Invoke(JSContext*, JS::CallArgs const&, js::MaybeConstruct)"},{"b":"56226F1E9000","o":"36D9D2F","s":"js::fun_apply(JSContext*, unsigned int, JS::Value*)"},{"b":"56226F1E9000","o":"38812C6","s":"js::Invoke(JSContext*, JS::CallArgs const&, js::MaybeConstruct)"},{"b":"56226F1E9000","o":"38925CD"},{"b":"56226F1E9000","o":"3880EE5","s":"js::RunScript(JSContext*, js::RunState&)"},{"b":"56226F1E9000","o":"38813CF","s":"js::Invoke(JSContext*, JS::CallArgs const&, js::MaybeConstruct)"},{"b":"56226F1E9000","o":"3881749","s":"js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandle<JS::Value>)"},{"b":"56226F1E9000","o":"36858E5","s":"JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>)"},{"b":"56226F1E9000","o":"316EFDD"},{"b":"56226F1E9000","o":"3173D28","s":"mongo::mozjs::MozJSImplScope::invoke(unsigned long long, mongo::BSONObj const*, mongo::BSONObj const*, int, bool, bool, bool)"},{"b":"56226F1E9000","o":"31BFF63"},{"b":"56226F1E9000","o":"31C5918"},{"b":"56226F1E9000","o":"288881E","s":"std::function<void ()>::operator()() const"},{"b":"56226F1E9000","o":"31C0767","s":"mongo::mozjs::MozJSProxyScope::implThread(void*)"},{"b":"56226F1E9000","o":"31BC648","s":"nspr::Thread::ThreadRoutine(void*)"},{"b":"56226F1E9000","o":"31BE826","s":"void* std::_Bind_simple<void* (*(nspr::Thread*))(void*)>::_M_invoke<0ul>(std::_Index_tuple<0ul>)"},{"b":"56226F1E9000","o":"31BE730","s":"std::_Bind_simple<void* (*(nspr::Thread*))(void*)>::operator()()"},{"b":"56226F1E9000","o":"31BE6C0","s":"std::thread::_Impl<std::_Bind_simple<void* (*(nspr::Thread*))(void*)> >::_M_run()"},{"b":"56226F1E9000","o":"499C1D0"},{"b":"7F4560C9A000","o":"76DB"},{"b":"7F45608A9000","o":"12188F","s":"clone"}],"processInfo":{ "mongodbVersion" : "0.0.0", "gitVersion" : "unknown", "compiledModules" : [ "ninja" ], "uname" : { "sysname" : "Linux", "release" : "4.15.0-20-generic", "version" : "#21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018", "machine" : "x86_64" }, "somap" : [ { "b" : "56226F1E9000", "elfType" : 3, "buildId" : "63BD8CD3C02FD0852B18102791799110326720B7" }, { "b" : "7FFCFDF74000", "path" : "linux-vdso.so.1", "elfType" : 3, "buildId" : "A0297FE29F8038EF50A10A26C9FCF5249CCC1184" }, { "b" : "7F4561A96000", "path" : "/usr/lib/x86_64-linux-gnu/libcurl.so.4", "elfType" : 3, "buildId" : "7F38B52E714BA83438F6FA23F00FA23AEC965339" }, { "b" : "7F456187B000", "path" : "/lib/x86_64-linux-gnu/libresolv.so.2", "elfType" : 3, "buildId" : "390E9CC4C215314B6D8ADE6D6E28F8518418039C" }, { "b" : "7F4561673000", "path" : "/lib/x86_64-linux-gnu/librt.so.1", "elfType" : 3, "buildId" : "9826FBDF57ED7D6965131074CB3C08B1009C1CD8" }, { "b" : "7F456146F000", "path" : "/lib/x86_64-linux-gnu/libdl.so.2", "elfType" : 3, "buildId" : "25AD56E902E23B490A9CCDB08A9744D89CB95BCC" }, { "b" : "7F45610D1000", "path" : "/lib/x86_64-linux-gnu/libm.so.6", "elfType" : 3, "buildId" : "A33761AB8FB485311B3C85BF4253099D7CABE653" }, { "b" : "7F4560EB9000", "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1", "elfType" : 3, "buildId" : "039AE85FEF075EC14FE3528762A0645C8CF73B29" }, { "b" : "7F4560C9A000", "path" : "/lib/x86_64-linux-gnu/libpthread.so.0", "elfType" : 3, "buildId" : "28C6AADE70B2D40D1F0F3D0A1A0CAD1AB816448F" }, { "b" : "7F45608A9000", "path" : "/lib/x86_64-linux-gnu/libc.so.6", "elfType" : 3, "buildId" : "B417C0BA7CC5CF06D1D1BED6652CEDB9253C60D0" }, { "b" : "7F4561D15000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "64DF1B961228382FE18684249ED800AB1DCEAAD4" }, { "b" : "7F4560684000", "path" : "/usr/lib/x86_64-linux-gnu/libnghttp2.so.14", "elfType" : 3, "buildId" : "4F00E5207693FDC249DA42EC6472ACA6A7B929AE" }, { "b" : "7F4560467000", "path" : "/usr/lib/x86_64-linux-gnu/libidn2.so.0", "elfType" : 3, "buildId" : "BA5BF9A5C44F48C647E9D8270A5421AE81CCAD61" }, { "b" : "7F456024B000", "path" : "/usr/lib/x86_64-linux-gnu/librtmp.so.1", "elfType" : 3, "buildId" : "69465D8AA6B19086ABF2455A703F9168BF82A69F" }, { "b" : "7F456003D000", "path" : "/usr/lib/x86_64-linux-gnu/libpsl.so.5", "elfType" : 3, "buildId" : "CDAF1F1946846941F9D06414EC8C812D131A168E" }, { "b" : "7F455FDD3000", "path" : "/usr/lib/x86_64-linux-gnu/libssl.so.1.1", "elfType" : 3, "buildId" : "9787FF1FFFE8D82268D89F6BFA3AF07B3E9D140F" }, { "b" : "7F455F95B000", "path" : "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1", "elfType" : 3, "buildId" : "95C6AB96CFE61B3B896F617C963E75A1ABAA99AC" }, { "b" : "7F455F710000", "path" : "/usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2", "elfType" : 3, "buildId" : "451E2EC02C8F974B21D1CE47F5D2C21A21C16A9F" }, { "b" : "7F455F4BE000", "path" : "/usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2", "elfType" : 3, "buildId" : "0CDDF9D1F87FE7FF07D73DBE1D7CB57EE5BA802C" }, { "b" : "7F455F2B0000", "path" : "/usr/lib/x86_64-linux-gnu/liblber-2.4.so.2", "elfType" : 3, "buildId" : "DD2893FC0AA3C58798F805D4C88EE086564D2EEB" }, { "b" : "7F455F093000", "path" : "/lib/x86_64-linux-gnu/libz.so.1", "elfType" : 3, "buildId" : "EF3E006DFE3132A41D4D4DC0E407D6EA658E11C4" }, { "b" : "7F455ED15000", "path" : "/usr/lib/x86_64-linux-gnu/libunistring.so.2", "elfType" : 3, "buildId" : "62A44D226F3A74CF720305A52D3E876E214C248A" }, { "b" : "7F455E9B0000", "path" : "/usr/lib/x86_64-linux-gnu/libgnutls.so.30", "elfType" : 3, "buildId" : "F67AAC89381F6ACFE9979B24D4002668C4F70ABE" }, { "b" : "7F455E77C000", "path" : "/usr/lib/x86_64-linux-gnu/libhogweed.so.4", "elfType" : 3, "buildId" : "842BDF0B0EAAB82E19F1EABFC38769F4040FBE31" }, { "b" : "7F455E546000", "path" : "/usr/lib/x86_64-linux-gnu/libnettle.so.6", "elfType" : 3, "buildId" : "C20D4B3BA13FCDCC3BF6857689BA9FC70BE3F6A5" }, { "b" : "7F455E2C5000", "path" : "/usr/lib/x86_64-linux-gnu/libgmp.so.10", "elfType" : 3, "buildId" : "D40EA9B5EC5BC46799E4A412319617BD38BE9341" }, { "b" : "7F455DFEF000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5.so.3", "elfType" : 3, "buildId" : "AFF9A2A2B6ACB066BF450CC4A0772B9DC04299CB" }, { "b" : "7F455DDBD000", "path" : "/usr/lib/x86_64-linux-gnu/libk5crypto.so.3", "elfType" : 3, "buildId" : "04AADCB371B97A570756D69A0D5B3B0E6737E349" }, { "b" : "7F455DBB9000", "path" : "/lib/x86_64-linux-gnu/libcom_err.so.2", "elfType" : 3, "buildId" : "9E885FB7F54DA464A3D2A978C71C1178A6EC7512" }, { "b" : "7F455D9AE000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5support.so.0", "elfType" : 3, "buildId" : "27A5983855C50A37EFA526BB12EA48CDAE3B5FCA" }, { "b" : "7F455D793000", "path" : "/usr/lib/x86_64-linux-gnu/libsasl2.so.2", "elfType" : 3, "buildId" : "ABB7E3F40302E6509DAD1F91DFB1F04B6A5FD072" }, { "b" : "7F455D552000", "path" : "/usr/lib/x86_64-linux-gnu/libgssapi.so.3", "elfType" : 3, "buildId" : "A1A98DB481968073636BBAECB561A3EA8ED198AE" }, { "b" : "7F455D223000", "path" : "/usr/lib/x86_64-linux-gnu/libp11-kit.so.0", "elfType" : 3, "buildId" : "8DBD451EA5651283905E16FA7DFA9908688893A3" }, { "b" : "7F455D010000", "path" : "/usr/lib/x86_64-linux-gnu/libtasn1.so.6", "elfType" : 3, "buildId" : "6036B89A3BB671B32E01464C0C82BFA016186352" }, { "b" : "7F455CE0C000", "path" : "/lib/x86_64-linux-gnu/libkeyutils.so.1", "elfType" : 3, "buildId" : "F463E107B099910463BC32E837C73D341A52C27B" }, { "b" : "7F455CC03000", "path" : "/usr/lib/x86_64-linux-gnu/libheimntlm.so.0", "elfType" : 3, "buildId" : "C2376C5B831991591F1A67B976758185F86896D8" }, { "b" : "7F455C976000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5.so.26", "elfType" : 3, "buildId" : "69BDEE5FA0FEEDF317308BE850F78761861D520A" }, { "b" : "7F455C6D4000", "path" : "/usr/lib/x86_64-linux-gnu/libasn1.so.8", "elfType" : 3, "buildId" : "315D74995AAA32DE4D15BA25F335066988B1B230" }, { "b" : "7F455C49E000", "path" : "/usr/lib/x86_64-linux-gnu/libhcrypto.so.4", "elfType" : 3, "buildId" : "6673972A1C24A89EBAFBAE696188A4CB26C6DDEB" }, { "b" : "7F455C288000", "path" : "/usr/lib/x86_64-linux-gnu/libroken.so.18", "elfType" : 3, "buildId" : "430827C33259C12248CF44B91A9A9821114376F5" }, { "b" : "7F455C080000", "path" : "/usr/lib/x86_64-linux-gnu/libffi.so.6", "elfType" : 3, "buildId" : "3555B5F599C9787DFDDBF9E8DF6F706B9044D985" }, { "b" : "7F455BE57000", "path" : "/usr/lib/x86_64-linux-gnu/libwind.so.0", "elfType" : 3, "buildId" : "93A0931B1C2818F0EA224CE6FE5E31E84A9B55BB" }, { "b" : "7F455BC48000", "path" : "/usr/lib/x86_64-linux-gnu/libheimbase.so.1", "elfType" : 3, "buildId" : "669D4CCE42FA4382796EFFCF0C16F459F4382C4C" }, { "b" : "7F455B9FE000", "path" : "/usr/lib/x86_64-linux-gnu/libhx509.so.5", "elfType" : 3, "buildId" : "4B80C543356EE0AF9039EFE7C9EA1CC1F74C426A" }, { "b" : "7F455B6F5000", "path" : "/usr/lib/x86_64-linux-gnu/libsqlite3.so.0", "elfType" : 3, "buildId" : "9FD7B69263297314C83BB205234E182BD4D8B86A" }, { "b" : "7F455B4BD000", "path" : "/lib/x86_64-linux-gnu/libcrypt.so.1", "elfType" : 3, "buildId" : "810686AF0D5FD350A4FB1CC4B5AFF44A05C102CB" } ] }} mongod(mongo::printStackTrace(std::ostream&) 0x36) [0x5622739eb968] mongod( 0x480192D) [0x5622739ea92d] mongod( 0x4801D9A) [0x5622739ead9a] libpthread.so.0( 0x12890) [0x7f4560cac890] libc.so.6(gsignal 0xC7) [0x7f45608e7e97] libc.so.6(abort 0x141) [0x7f45608e9801] mongod(mongo::invariantFailedWithMsg(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, unsigned int) 0x0) [0x5622739def8c] mongod(void mongo::invariantWithLocation<bool>(bool const&, char const*, char const*, unsigned int) 0x3F) [0x562271a14093] mongod(mongo::OperationContext::setLogicalSessionId(mongo::LogicalSessionId) 0x4D) [0x56227391fed1] mongod(mongo::initializeOperationSessionInfo(mongo::OperationContext*, mongo::BSONObj const&, bool, bool, bool) 0x267) [0x56227314a80b] mongod( 0x289018C) [0x562271a7918c] mongod( 0x2892D5E) [0x562271a7bd5e] mongod( 0x2893590) [0x562271a7c590] mongod(mongo::ServiceEntryPointCommon::handleRequest(mongo::OperationContext*, mongo::Message const&, mongo::ServiceEntryPointCommon::Hooks const&) 0x43D) [0x562271a7e821] mongod(mongo::ServiceEntryPointMongod::handleRequest(mongo::OperationContext*, mongo::Message const&) 0x54) [0x562271a658e4] mongod( 0x3E1BD67) [0x562273004d67] mongod(mongo::DBDirectClient::call(mongo::Message&, mongo::Message&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) 0x53) [0x562273004e59] mongod(mongo::DBClientBase::runCommandWithTarget(mongo::OpMsgRequest) 0x223) [0x5622732291df] mongod(mongo::DBClientBase::runCommandWithTarget(mongo::OpMsgRequest, std::shared_ptr<mongo::DBClientBase>) 0x68) [0x56227322944a] mongod(mongo::DBClientBase::runCommandWithTarget(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mongo::BSONObj, mongo::BSONObj&, std::shared_ptr<mongo::DBClientBase>, int) 0xEB) [0x562273229797] mongod(mongo::mozjs::MongoBase::Functions::runCommand::call(JSContext*, JS::CallArgs) 0x258) [0x5622723812b0] mongod(bool mongo::mozjs::smUtils::wrapConstrainedMethod<mongo::mozjs::MongoBase::Functions::runCommand, true, mongo::mozjs::MongoLocalInfo, mongo::mozjs::MongoExternalInfo>(JSContext*, unsigned int, JS::Value*) 0x166) [0x56227238e1ae] mongod(js::Invoke(JSContext*, JS::CallArgs const&, js::MaybeConstruct) 0x39A) [0x562272a6a2c6] mongod(js::fun_apply(JSContext*, unsigned int, JS::Value*) 0x593) [0x5622728c2d2f] mongod(js::Invoke(JSContext*, JS::CallArgs const&, js::MaybeConstruct) 0x39A) [0x562272a6a2c6] mongod( 0x38925CD) [0x562272a7b5cd] mongod(js::RunScript(JSContext*, js::RunState&) 0x1F7) [0x562272a69ee5] mongod(js::Invoke(JSContext*, JS::CallArgs const&, js::MaybeConstruct) 0x4A3) [0x562272a6a3cf] mongod(js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandle<JS::Value>) 0x302) [0x562272a6a749] mongod(JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) 0xCF) [0x56227286e8e5] mongod( 0x316EFDD) [0x562272357fdd] mongod(mongo::mozjs::MozJSImplScope::invoke(unsigned long long, mongo::BSONObj const*, mongo::BSONObj const*, int, bool, bool, bool) 0x462) [0x56227235cd28] mongod( 0x31BFF63) [0x5622723a8f63] mongod( 0x31C5918) [0x5622723ae918] mongod(std::function<void ()>::operator()() const 0x32) [0x562271a7181e] mongod(mongo::mozjs::MozJSProxyScope::implThread(void*) 0x15F) [0x5622723a9767] mongod(nspr::Thread::ThreadRoutine(void*) 0x36) [0x5622723a5648] mongod(void* std::_Bind_simple<void* (*(nspr::Thread*))(void*)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) 0x40) [0x5622723a7826] mongod(std::_Bind_simple<void* (*(nspr::Thread*))(void*)>::operator()() 0x2C) [0x5622723a7730] mongod(std::thread::_Impl<std::_Bind_simple<void* (*(nspr::Thread*))(void*)> >::_M_run() 0x1C) [0x5622723a76c0] mongod( 0x499C1D0) [0x562273b851d0] libpthread.so.0( 0x76DB) [0x7f4560ca16db] libc.so.6(clone 0x3F) [0x7f45609ca88f] ----- END BACKTRACE -----