Skip to content

Commit

Permalink
SERVER-10382 add error code if count command is interrupted
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
  • Loading branch information
dstorch authored and kangas committed Oct 3, 2013
1 parent 1ccb9e9 commit 1819d00
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions jstests/count10.js
@@ -0,0 +1,34 @@
// interrupting a count returns an error code

t = db.count10;
t.drop();

for ( i=0; i<100; i++ ){
t.save( { x : i } );
}
// make sure data is written
db.getLastError();

var thr = new Thread(function () {
try {
db.count10.find("sleep(1000)").count();
}
catch (e) {
return e;
}
});

thr.start();
sleep(1000);

current = db.currentOp({"ns": t.getFullName(), "query.count": t.getName()});
assert(current);
countOp = current.inprog[0];
assert(countOp);

db.killOp(countOp.opid);
res = thr.returnData();

assert(res);
assert(res.match(/count failed/) !== null);
assert(res.match(/\"code\"/) !== null);
1 change: 1 addition & 0 deletions src/mongo/db/dbcommands.cpp
Expand Up @@ -593,6 +593,7 @@ namespace mongo {
ok = false;
if ( !err.empty() ) {
errmsg = err;
result.append("code", errCode);
return false;
}
}
Expand Down

0 comments on commit 1819d00

Please sign in to comment.