MongoServerError: PlanExecutor error during aggregation :: caused by :: Out of memory

It runs successfully in mongodb version 5.0+, but fails in version 6.0, why???

version:6.0.6

mongo.log

"planSummary": "COLLSCAN",
		"numYields": 225,
		"queryHash": "FB805F4B",
		"queryFramework": "classic",
		"ok": 0,
		"errMsg": "PlanExecutor error during aggregation :: caused by :: Out of memory",
		"errName": "JSInterpreterFailure",
		"errCode": 139,
		"reslen": 163,

my code

db.user_103_tmp.aggregate([
    {
        $project: {
            emits: {
                k: "$groupid",
                v: {
                   ...
                }
            }
        }
    },
    {
        $unwind: "$emits"
    },
    {
        $group: {
            _id: "$emits.k",
            value: {
                $accumulator: {
                    init: function() {
                        return {
                            d: []
                        };
                    },
                    initArgs: [],
                    accumulate: function(state, values) {
                        state.d.push(JSON.stringify(values));
                        return state;
                    },
                    accumulateArgs: ["$emits.v"],
                    merge: function(state1, state2) {
                        return {
                            d: state1.d.concat(state2.d)
                        };
                    },
                    finalize: function(state) {
                        return state.d
                    },
                    lang: "js"
                }
            }
        }
    },
    {
        $out: "user_103_group"
    }
], {
    allowDiskUse: true
})

Hi @lijinhua6324,

It runs successfully in mongodb version 5.0+, but fails in version 6.0, why???

To help us troubleshoot it would help to understand a few things about the environments you’re working in.

  • Are the environments you’re running 5.0 and 6.0 identical? (same hardware, memory, etc)
  • Is the data identical in user_103_tmp when testing this in both 5.0 and 6.0?
  • How many documents are in user_103_tmp?
  • Can you share a sample document from user_103_tmp?
  • Are you testing this locally using a standalone mongod process?
  • Have you tuned your mongod configuration at all or just using the defaults?

The goal here is to reproduce the behavior you’ve described so we can determine the source of the issue.

1 Like

I solved it using the following

db.user_103_tmp.aggregate([
  {
    $group: {
      _id: "$userid",
      v: { $push: "$$ROOT" }
    }
  }
  {
        $out: "user_103_group"
    }
])

This topic was automatically closed after 180 days. New replies are no longer allowed.