Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-17616

Removing or inserting documents with large indexed arrays consumes excessive memory

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.0.2, 3.1.1
    • Component/s: MMAPv1
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Completed:
    • Sprint:
      Quint Iteration 3.1.1

      Description

      Issue Status as of Apr 02, 2015

      ISSUE SUMMARY
      A mongod using the MMAPv1 storage engine may use too much memory to insert and remove documents with large indexed arrays.

      USER IMPACT
      MongoDB consumes an unnecessarily large amount of memory.

      WORKAROUNDS
      None.

      AFFECTED VERSIONS
      MongoDB 3.0.0 and 3.0.1 are affected by this issue.

      FIX VERSION
      The fix is included in the 3.0.2 production release.

      Original description

      Reproduce as follows:

          db.c.ensureIndex({a:1})
          doc = {a:[]}
          for (var i=0; i<100000; i++)
              doc.a.push(i)
          db.c.insert(doc)
          print('before:', db.serverStatus({tcmalloc:1}).tcmalloc.generic.heap_size/1024/1024, 'MB')
          db.c.remove({})
          print('after:', db.serverStatus({tcmalloc:1}).tcmalloc.generic.heap_size/1024/1024, 'MB')
      

      Results:

      3.0, mmapv1, 100k entries:
      before: 124.9453125 MB
      after: 3148.9453125 MB <===
       
      3.0, mmapv1, 50k entries:
      before: 93.234375 MB
      after: 1605.234375 MB <===
       
      3.0, wiredTiger, 100k entries:
      before: 72.28125 MB
      after: 98.53125 MB
       
      2.6.8, mmapv1, 100k entries
      before: 79.4453125 MB
      after: 79.4453125 MB
      

      • memory consumed is proportional to number of index entries, about 30 kB per entry
      • issue is specific to mmapv1, does not occur with WT - so maybe issue is in the journal?
      • problem does not occur in 2.6

        Attachments

          Activity

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: