Handle NotFound exception when declaring a queue

Catch and handle the NotFound exception when declaring a queue.
This exception occurs when attempting to declare a queue that already
exists and is non-durable, non-HA, and hosted on a node that has
recently gone down.

Closes-Bug: #2068630
Change-Id: I637d931242c64465701266149d5e301f9b5ec4de
This commit is contained in:
viktor-krivak 2024-06-07 10:30:48 +00:00 committed by Michal Arbet
parent 82d6287065
commit 0d3338fd1d
2 changed files with 29 additions and 0 deletions

View File

@ -486,6 +486,29 @@ class Consumer(object):
'because of conflicting configurations: %s',
conn.connection_id, self.queue_name, err)
self._declare_fallback(err, conn, consumer_arguments)
except amqp_ex.NotFound as ex:
# NOTE(viktor.krivak): This exception is raised when
# non-durable and non-ha queue is hosted on node that
# is currently unresponsive or down. Thus, it is
# not possible to redeclare the queue since its status
# is unknown, and it could disappear in
# a few moments. However, the queue could be explicitly
# deleted and the redeclaration will then succeed.
# Queue will be then scheduled on any of the
# running/responsive nodes.
# This fixes bug:
# https://bugs.launchpad.net/oslo.messaging/+bug/2068630
LOG.warning("Queue %s is stuck on unresponsive node. "
"Trying to delete the queue and redeclare it "
"again, Error info: %s", self.queue_name, ex)
try:
self.queue.delete()
except Exception as in_ex:
LOG.warning("During cleanup of stuck queue deletion "
"another exception occurred: %s. Ignoring...",
in_ex)
self.queue.declare()
except conn.connection.channel_errors as exc:
# NOTE(jrosenboom): This exception may be triggered by a race

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Force queue deletion when it is not possible de redeclare a queue.
See `bug 2068630 <https://launchpad.net/bugs/2068630>`__
for details.