[SERVER-25366] mongo shell fails to kill running operations on exit Created: 31/Jul/16  Updated: 13/Aug/16  Resolved: 02/Aug/16

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.1.2
Fix Version/s: 3.3.11

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

To see the assertion message from the server, start the mongod with log-level 1.

> db.mycoll.drop();
> db.mycoll.insert({});
> db.mycoll.find({$where: "sleep(10000)"});
^C
do you want to kill the current op(s) on the server? (y/n): y

Server output

2016-07-31T15:00:20.388-0400 I COMMAND  [conn6] command admin.$cmd command: currentOp { currentOp: 1 } keyUpdates:0 writeConflicts:0 numYields:0 reslen:935 locks:{} protocol:op_query 0ms
2016-07-31T15:00:21.298-0400 D -        [conn6] User Assertion: 14:Expected field "op" to have numeric type, but found String
2016-07-31T15:00:21.298-0400 D COMMAND  [conn6] assertion while executing command 'killOp' on database 'admin' with arguments '{ killOp: 1, op: "opid: 306" }' and metadata '{}': 14 Expected field "op" to have numeric type, but found String
2016-07-31T15:00:21.298-0400 I COMMAND  [conn6] command admin.$cmd command: killOp { killOp: 1, op: "opid: 306" } keyUpdates:0 writeConflicts:0 exception: Expected field "op" to have numeric type, but found String code:14 numYields:0 reslen:118 locks:{} protocol:op_query 0ms

Sprint: Query 18 (08/05/16)
Participants:

 Description   

This is a regression to ConnectionRegistry::killOperationsOnAllConnections() introduced by the changes from SERVER-7775 with the addition of the "killOp" command: https://github.com/mongodb/mongo/commit/d6cd29d1fc0594657fcb2b69ce8334df85f9ba54#diff-629362cc5e412256e6879e87f489a3a6.

In verisons of the mongo shell prior to 3.1.2, the arguments sent to the server were constructed using

QUERY("op"<< op["opid"])
// which expands to
BSON("op"<< op["opid"])
// which expands to
(::mongo::BSONObjBuilder(64) << "op"<< op["opid"]).obj()
 
// which makes the following chain of function calls
BSONObjBuilder::BSONObjBuilder(int initsize);
BSONObjBuilder::operator<<(StringData name);
BSONObjBuilderValueStream::operator<<(const BSONElement& e);
BSONObjBuilder::appendAs(const BSONElement& e, StringData fieldName);
...

However, in versions of the mongo shell 3.1.2 and later, the arguments sent to the server were constructed using

BSONObjBuilder::BSONObjBuilder(int initsize);
BSONObjBuilder::append(StringData fieldName, const std::string& str);

by implicitly calling BSONElement::operator std::string() and thus creating an object of the form {op: "opid: <opid>"} instead of {op: <opid>}.



 Comments   
Comment by Githook User [ 02/Aug/16 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-25366 Fix killOp arguments sent by the mongo shell on exit.
Branch: master
https://github.com/mongodb/mongo/commit/ddeb9a839090a732adfa7a500c93f3cfbddce9d5

Generated at Thu Feb 08 04:09:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.