Atlas error: QueryExceededMemoryLimitNoDiskUseAllowed
A sort or aggregation stage blew past the 100MB in-memory limit. The fix is an index on the sort, not just flipping allowDiskUse.
TL;DR: A sort or aggregation stage blew past the 100MB in-memory limit. The fix is an index on the sort, not just flipping allowDiskUse. Confirm Run the query with explain("executionStats"). Fix, in order 1.
The fix
- Index the sort: an index on the sort keys (matching sort direction) lets the query stream in order with no in-memory sort at all. This is the real fix.
- Reduce the working set: push
$matchearlier,$projectaway unneeded fields before the heavy stage.
- Only then consider
allowDiskUse: trueon the aggregation. It spills to disk and finishes, but slowly. Treat it as a bandage while the index builds, not the solution.
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: Atlas error.
- You want the fastest verified fix before digging through logs.
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
- Not pinned to a specific version; follows current Atlas behavior.
When to use this
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: Atlas error.
- You want the fastest verified fix before digging through logs.
When not to use this
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.