Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

PyMongo 2.6.1 Released With Refleak Fix

DZone's Guide to

PyMongo 2.6.1 Released With Refleak Fix

· Web Dev Zone ·
Free Resource

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

Leak

Bernie Hackett and I released PyMongo 2.6.1 yesterday. This version fixes a bug in PyMongo 2.6, a reference-count leak in insert() that caused memory to grow slowly without bound. Please upgrade immediately.

Sorry about the bug. We introduced it into PyMongo's C code while implementing auto-splitting for very large batch inserts, but it affects all calls to insert regardless of size. If you use PyMongo without building its C extensions, for example if you're on PyPy or Jython, the bug does not affect you.

The new auto-splitting code serializes a sequence of documents as BSON until its buffer reaches 48MB, at which point it calls, from C, the Python method _send_message to fire off the batch to the server. Unfortunately, the C code didn't dereference the server response from _send_message. The response is small, something like this:

{'ok': 1.0, 'err': None, 'n': 0, 'connectionId': 123}

Each response was leaked, and the memory added up fast if you called insert in a tight loop. The fix is simply to decref the response.

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}