allowDiskUse Bug?

Ronny Klaeboe shared this problem 2 years ago
Not a Problem

Works

db.position.aggregate([

{$sample: {size: 10000}},

{$out:"pos10000"}],

{allowDiskUse:true})

Does not

db.position.aggregate()

.sample(10000)

.out('pos10000')

.allowDiskUse()

{

"message" : "Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.",

"ok" : 0,

"code" : 16820,

"codeName" : "Location16820",

"name" : "MongoError"

}

version 6.2.13, Ubuntu 20.04LTS Mongod v4.2.9 64 bit

file 0.19M 2.1GB

Replies (3)

photo
1

I noticed that you used the out stage. According to the MongoDB document, out must be the last stage. The allowDiskUse option after "out" has been ignored. You can try to put the allowDiskUse before.


db.position.aggregate()
.allowDiskUse() //Set allowDiskUse option here
.sample(10000)
.out('pos10000')

photo
1

Thanks,

That made all the difference. Now works OK :-).

I regarded allowDiskUse() as an option, and not a stage, and thus failed to recognize any confilct with out() as last stage.rquirement

Thaks a lot, this is the type of problem I spent a lot of effort on, even though the solution / when you learn it / is extremely simple

photo
1

The $out/$merge is executed differently from other stages. Internally, it does not return a normal cursor. If allowDiskUse is later, it doesn't have a chance to execute the allowDiskUse () method at all. We need to modify the type definition of out/merge chain method so that I no longer return AggregationCursor to avoid misunderstanding.

Leave a Comment
 
Attach a file