[SERVER-4844] can't killop an aggregation operation Created: 01/Feb/12  Updated: 11/Jul/16  Resolved: 16/Feb/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 2.1.1

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Chris Westin
Resolution: Done Votes: 0
Labels: pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-447 new aggregation framework Closed
Related
related to SERVER-4984 make it possible to interrupt operati... Closed
Operating System: ALL
Participants:

 Description   

Ran a long aggregation operation, wasn't able to kill it with killop and ctrl-c on mongod also seems to hang until the operation finishes.

Here is the test I ran

c = db.c;
c.drop();
 
big = new Array(1000).toString();
for( i = 0; i < 10; ++i ) {
    c.save( {b:big} );
}
 
pipeline = [];
for( i = 0; i < 100; ++i ) {
    pipeline.push( {$skip:1} );
}
 
c.aggregate( pipeline );
 



 Comments   
Comment by Githook User [ 23/Oct/14 ]

Author:

{u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}

Message: SERVER-4844 Fix typo in $limit comment

Closes #836

Signed-off-by: Benety Goh <benety@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/ae7861b3333b6b4b940b2a1ab6267a0140294ee9

Comment by auto [ 16/Feb/12 ]

Author:

{u'login': u'cwestin', u'name': u'U-tellus\\cwestin', u'email': u'cwestin@10gen.com'}

Message: SERVER-4844
Branch: master
https://github.com/mongodb/mongo/commit/81eb12828d423fe3bdee3952d67823c57c1f51ea

Comment by auto [ 16/Feb/12 ]

Author:

{u'login': u'cwestin', u'name': u'U-tellus\\cwestin', u'email': u'cwestin@10gen.com'}

Message: SERVER-4844
Branch: master
https://github.com/mongodb/mongo/commit/0b57ab6a14e9e67dd4050c423fadc15e79709fbc

Comment by auto [ 16/Feb/12 ]

Author:

{u'login': u'cwestin', u'name': u'U-tellus\\cwestin', u'email': u'cwestin@10gen.com'}

Message: SERVER-4844
Branch: master
https://github.com/mongodb/mongo/commit/7ada09610e73211856e4ca906eb06d54d2354641

Comment by Chris Westin [ 16/Feb/12 ]

When testing my fix, I discovered that the test above is a red herring: there's a different problem wherein chained $skips interact with each other weirdly, and get stuck. I fixed that by implementing DocumentSource::coalesce() for them, which optimizes them all by collapsing adjacent ones (adjacent skips become a single skip with the sum of the skip values). Once I did that, this script no longer took any time at all, and couldn't be used to reproduce the inability to interrupt aggregation pipelines.

For the real problem, I used the following to reproduce the problem:

db = db.getSiblingDB('qa');
 
db.t.drop();
for(i = 0; i < 1000000; ++i) {
    db.t.save({a:i, b:[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]});
}
 
var ar = db.runCommand({aggregate:"t", pipeline:[
    {$unwind:"$b"},
    {$group: {
        _id: "$b",
        c: {$sum: 1},
        s: {$sum: "$a"}
    }}
]});

This takes long enough that you can catch it with db.currentOp(), and kill it with db.killOp().

Currently waiting for problems w/github to be resolved so I can push.

Comment by auto [ 15/Feb/12 ]

Author:

{u'login': u'cwestin', u'name': u'U-tellus\\cwestin', u'email': u'cwestin@10gen.com'}

Message: checkpoint SERVER-4844
Branch: master
https://github.com/mongodb/mongo/commit/be91e89eae5f8461d51708ffde59fa35a06230bb

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