fix(storage.mongodb) Empty bulk insert fails

Bug #1169838 reported by Kurt Griffiths
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zaqar
Fix Released
High
Kurt Griffiths

Bug Description

Repo:

http://166.78.143.130/v1/1874/queues/alerts/messages -H "Client-ID: Foo" -d '{}' -v

Expected:

400 status returned to client

Actual:

Traceback (most recent call last):
  File "api.py", line 83, in falcon.api.API.__call__ (falcon/api.c:1370)
  File "/home/marconi/marconi-app/marconi/transport/wsgi/messages.py", line 53, in on_post
    client_uuid=uuid)
  File "/home/marconi/marconi-app/marconi/storage/mongodb/controllers.py", line 302, in post
    self._col.insert(denormalizer(messages), manipulate=False)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 357, in insert
    continue_on_error, self.__uuid_subtype), safe)
pymongo.errors.InvalidOperation: cannot do an empty bulk insert

Revision history for this message
Flavio Percoco (flaper87) wrote :
Changed in marconi:
status: New → Fix Committed
assignee: nobody → Kurt Griffiths (kgriffs)
Revision history for this message
Malini Kamalambal (malini-pk) wrote :

Tested with the latest code & the original issue still exists.

3-05-22 11:51:37.130 4191 ERROR marconi.transport.wsgi.messages [-] cannot do an empty bulk insert
2013-05-22 11:51:37.130 4191 TRACE marconi.transport.wsgi.messages Traceback (most recent call last):
2013-05-22 11:51:37.130 4191 TRACE marconi.transport.wsgi.messages File "/Users/malini.kamalambal/marconi/marconi/transport/wsgi/messages.py", line 51, in on_post
2013-05-22 11:51:37.130 4191 TRACE marconi.transport.wsgi.messages client_uuid=uuid)
2013-05-22 11:51:37.130 4191 TRACE marconi.transport.wsgi.messages File "/Users/malini.kamalambal/marconi/marconi/storage/mongodb/controllers.py", line 329, in post
2013-05-22 11:51:37.130 4191 TRACE marconi.transport.wsgi.messages ids = self._col.insert(denormalizer(messages))
2013-05-22 11:51:37.130 4191 TRACE marconi.transport.wsgi.messages File "/Library/Python/2.7/site-packages/pymongo-2.5-py2.7-macosx-10.7-intel.egg/pymongo/collection.py", line 357, in insert

Kurt Griffiths (kgriffs)
Changed in marconi:
status: Fix Committed → In Progress
Revision history for this message
Kurt Griffiths (kgriffs) wrote :

I'm on it.

Revision history for this message
Kurt Griffiths (kgriffs) wrote :

Hmm. Are you sure you have the latest code? I am unable to repro from a unit test.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to marconi (master)

Fix proposed to branch: master
Review: https://review.openstack.org/30148

Revision history for this message
Kurt Griffiths (kgriffs) wrote :

OK, I've got a repo now added to the unit tests. Turns out it is only with an empty list of messages "[]" and only with the mongodb driver. Sending "{}" works as expected.

Revision history for this message
Kurt Griffiths (kgriffs) wrote :

Fix is ready, just needs to be approved.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to marconi (master)

Reviewed: https://review.openstack.org/30148
Committed: http://github.com/stackforge/marconi/commit/662ea8096ae5e69c456d19c7bb32a404e7993705
Submitter: Jenkins
Branch: master

commit 662ea8096ae5e69c456d19c7bb32a404e7993705
Author: kgriffs <email address hidden>
Date: Wed May 22 14:52:54 2013 -0300

    Properly handle message post with an empty iterable.

    Storage drivers expect at least one item in messages iterable,
    so I modified the WSGI driver to check when this is not
    the case and return an error response to the client rather
    than blindly passing the messages generator into the
    driver's post method.

    Fixes: bug #1169838

    Change-Id: Ia2e512138a465af70110d88e8e11ae58ee5e4aab

Changed in marconi:
status: In Progress → Fix Committed
Changed in marconi:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.