# MongoDB Integration generates huge amount of temp files

**URL:** <https://discuss.elastic.co/t/mongodb-integration-generates-huge-amount-of-temp-files/350226>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [January 2, 2024, 10:58am UTC](https://discuss.elastic.co/t/mongodb-integration-generates-huge-amount-of-temp-files/350226 "2024-01-02T10:58:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SnackK](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@SnackK](https://discuss.elastic.co/u/SnackK)\
**Post date:** [January 2, 2024, 10:58am UTC](https://discuss.elastic.co/t/mongodb-integration-generates-huge-amount-of-temp-files/350226/1 "2024-01-02T10:58:39Z")

</div>

Recently something generated 80Gb of temp files under 15 minutes in my primary MongoDB. I disabled the DiskUse then I got the following errors:  
**Plan executor error during find command**

```auto
  "stats": {
    "works": 88450,
    "restoreState": 88,
    "saveState": 88,
    "advanced": 0,
    "spilledDataStorageSize": 0,
    "nReturned": 0,
    "inputStage": {
      "works": 88450,
      "restoreState": 88,
      "stage": "COLLSCAN",
      "saveState": 88,
      "advanced": 88450,
      "nReturned": 88450,
      "needYield": 0,
      "docsExamined": 88450,
      "needTime": 0,
      "isEOF": 0,
      "direction": "forward"
    },
    "failed": true,
    "usedDisk": false,
    "type": "simple",
    "isEOF": 0,
    "memLimit": 104857600,
    "stage": "SORT",
    "sortPattern": {
      "-$natural": 1
    },
    "needYield": 0,
    "needTime": 88449,
    "totalDataSizeSorted": 0,
    "spills": 0
  },
  "cmd": {
    "filter": {},
    "lsid": {
      "id": {
        "$uuid": "2617b402-0c61-4035-bc39-d616e412fbb3"
      }
    },
    "$readPreference": {
      "mode": "primary"
    },
    "$db": "local",
    "$clusterTime": {
      "clusterTime": {
        "$timestamp": {
          "t": 1704123123,
          "i": 1
        }
      },
      "signature": {
        "keyId": 0,
        "hash": {
          "$binary": {
            "base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
            "subType": "0"
          }
        }
      }
    },
    "find": "oplog.rs",
    "sort": {
      "-$natural": 1
    }
  },
  "error": {
    "code": 292,
    "codeName": "QueryExceededMemoryLimitNoDiskUseAllowed",
    "errmsg": "Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting."
  }
}

```

As you can see it uses the sort wrong, it should be "$natural": -1

Can I disable that query until they fix it?

I have found a similar topic with no answer:

> [@Metricbeat 8.8.1 MongoDB module - Error fetching data replstatus: sort operation used more than the maximum bytes of RAM](https://discuss.elastic.co/t/metricbeat-8-8-1-mongodb-module-error-fetching-data-replstatus-sort-operation-used-more-than-the-maximum-bytes-of-ram/348057):
>
> When trying to set up the mongodb.replstatus metricset on my replica set (MongoDB v3.6), I am given the error: Error fetching data for metricset mongodb.replstatus: error getting replication info: could not get last operation timestamp in oplog: could not get cursor on collection 'oplog.rs': (OperationFailed) Executor error during find command :: caused by :: errormsg: "Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit." My oplog collecti…

Can I file an issue ticket somewhere?

---

<div class="post-metadata">

**Author:** ![strawgate](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/strawgate/32/131008_2.png) [@strawgate](https://discuss.elastic.co/u/strawgate)\
**Post date:** [January 23, 2024, 2:57am UTC](https://discuss.elastic.co/t/mongodb-integration-generates-huge-amount-of-temp-files/350226/2 "2024-01-23T02:57:24Z")

</div>

If you have a support contract I would recommend starting there otherwise if you're using a fleet managed integration you can file a ticket in GitHub here: [Issues · elastic/integrations · GitHub](https://github.com/elastic/integrations/issues)

---

<div class="post-metadata">

**Author:** ![Richa\_Talwar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richa_talwar/32/119114_2.png) [@Richa\_Talwar](https://discuss.elastic.co/u/Richa_Talwar)\
**Post date:** [January 31, 2024, 11:32am UTC](https://discuss.elastic.co/t/mongodb-integration-generates-huge-amount-of-temp-files/350226/3 "2024-01-31T11:32:07Z")

</div>

The issue has been [acknowledged](https://github.com/elastic/integrations/issues/8683) and fixed, and it will be available in the next release.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 28, 2024, 1:32pm UTC](https://discuss.elastic.co/t/mongodb-integration-generates-huge-amount-of-temp-files/350226/4 "2024-02-28T13:32:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
