From d15f3034dfab05ef0ec02b4e353b3dfa1512db35 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Tue, 12 Jun 2012 17:07:18 -0400 Subject: [PATCH] Add missing ack to impl_qpid. Fix bug 1012374. Johannes Erdfelt pointed out that impl_qpid wasn't acking messages that it received. This turned out to be a nasty oversight, resulting in unbounded message queue growth inside of the python-qpid library. This fixes it. Change-Id: I0370293807f0282e1dbdd59246f70be031e888a9 --- nova/rpc/impl_qpid.py | 7 ++++++- nova/tests/rpc/test_qpid.py | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nova/rpc/impl_qpid.py b/nova/rpc/impl_qpid.py index 4044ec03ae7..c5ab4a1d55b 100644 --- a/nova/rpc/impl_qpid.py +++ b/nova/rpc/impl_qpid.py @@ -137,7 +137,12 @@ def reconnect(self, session): def consume(self): """Fetch the message and pass it to the callback object""" message = self.receiver.fetch() - self.callback(message.content) + try: + self.callback(message.content) + except Exception: + LOG.exception(_("Failed to process message... skipping it.")) + finally: + self.session.acknowledge(message) def get_receiver(self): return self.receiver diff --git a/nova/tests/rpc/test_qpid.py b/nova/tests/rpc/test_qpid.py index 1b21158f897..b8553873bc0 100644 --- a/nova/tests/rpc/test_qpid.py +++ b/nova/tests/rpc/test_qpid.py @@ -296,6 +296,7 @@ def _test_call(self, multi): self.mock_receiver) self.mock_receiver.fetch().AndReturn(qpid.messaging.Message( {"result": "foo", "failure": False, "ending": False})) + self.mock_session.acknowledge(mox.IgnoreArg()) if multi: self.mock_session.next_receiver(timeout=mox.IsA(int)).AndReturn( self.mock_receiver) @@ -303,16 +304,19 @@ def _test_call(self, multi): qpid.messaging.Message( {"result": "bar", "failure": False, "ending": False})) + self.mock_session.acknowledge(mox.IgnoreArg()) self.mock_session.next_receiver(timeout=mox.IsA(int)).AndReturn( self.mock_receiver) self.mock_receiver.fetch().AndReturn( qpid.messaging.Message( {"result": "baz", "failure": False, "ending": False})) + self.mock_session.acknowledge(mox.IgnoreArg()) self.mock_session.next_receiver(timeout=mox.IsA(int)).AndReturn( self.mock_receiver) self.mock_receiver.fetch().AndReturn(qpid.messaging.Message( {"failure": False, "ending": True})) + self.mock_session.acknowledge(mox.IgnoreArg()) self.mock_session.close() self.mock_connection.session().AndReturn(self.mock_session)