- 
    Type:Bug 
- 
    Resolution: Done
- 
    Priority:Major - P3 
- 
    Affects Version/s: None
- 
    Component/s: Aggregation Framework, Sharding
- 
        Fully Compatible
- 
        ALL
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
It seems like when running an aggregation command against a sharded cluster that causes a spill to disk and having allowDiskUse: false it is possible for a non-error document to be returned.
The test to reproduce this is "multi_spill_2.js", I am running it with the following command:
python buildscripts/smoke.py --mongo=/Users/ace/neweng/mongo/mongo --mongod=/Users/ace/neweng/mongo/mongod --continue-on-failure --test-path=/Users/ace/repro --mode=files /Users/ace/repro/multi_spill_2.js > ms2.out
Snippits from the output:
m30000| 2014-02-12T14:17:34.261-0800 [conn10] getmore aggShard.qa369_multi_2 cursorid:23609826722 ntoreturn:0 keyUpdates:0 exception: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to op t in. code:16819 numYields:13 locks(micros) r:15175 nreturned:1 reslen:186 15ms m30001| 2014-02-12T14:17:34.261-0800 [conn9] getmore aggShard.qa369_multi_2 cursorid:22109034986 ntoreturn:0 keyUpdates:0 exception: S ort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in. code:16819 numYields:13 locks(micros) r:15325 nreturned:1 reslen:186 15ms
But then the result:
assert: command worked when it should have failed: { "result" : [ { "_id" : "" } ], "ok" : 1 } : undefined
Buildinfo for version I tested against:
> db.runCommand({buildinfo:1})
{
        "version" : "2.5.6-pre-",
        "gitVersion" : "9f847a1a91a7f1861733ce6fe1617da89dd945c0",
        "OpenSSLVersion" : "",
        "sysInfo" : "Darwin Andrew-Emil-MacBook-Pro.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49",
        "loaderFlags" : "-fPIC -pthread -Wl,-bind_at_load -mmacosx-version-min=10.6",
        "compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-function -Wno-deprecated-declarations -mmacosx-version-min=10.6",
        "allocator" : "tcmalloc",
        "versionArray" : [
                2,
                5,
                6,
                -100
        ],
        "javascriptEngine" : "V8",
        "bits" : 64,
        "debug" : false,
        "maxBsonObjectSize" : 16777216,
        "ok" : 1
}