matchmaker_redis: ack_alive fails with KeyError on re-registration attempt

Bug #1419718 reported by Ihar Hrachyshka
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.messaging
Fix Released
Undecided
qiaojian

Bug Description

    def ack_alive(self, key, host):
        topic = "%s.%s" % (key, host)
        if not self.redis.expire(topic, CONF.matchmaker_heartbeat_ttl):
            # If we could not update the expiration, the key
            # might have been pruned. Re-register, creating a new
            # key in Redis.
            self.register(self.host_topic[host], host)

Note that self.host_topic is a dict with keys of tuple (key, host), not 'host'. So in case the thread gets under if, it fails immediately.

Also note that just fixing it to pass (key, host) does not help either since in that case we get into indefinite recursion, ack_alive() calling to register() calling back to ack_alive().

Tags: zmq
Mehdi Abaakouk (sileht)
tags: added: zmq
qiaojian (qiaojian)
Changed in oslo.messaging:
assignee: nobody → qiaojian (qiaojian)
Changed in oslo.messaging:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.messaging (master)

Reviewed: https://review.openstack.org/155673
Committed: https://git.openstack.org/cgit/openstack/oslo.messaging/commit/?id=e8def40a4149651b69d0ed8fa1bdbbb431912f27
Submitter: Jenkins
Branch: master

commit e8def40a4149651b69d0ed8fa1bdbbb431912f27
Author: joyce <email address hidden>
Date: Fri Feb 13 16:21:30 2015 +0800

    Fix matchmaker_redis ack_alive fails with KeyError

    Fix matchmaker_redis: ack_alive fails with KeyError on re-registration
    attempt.

    def ack_alive(self, key, host):
        topic = "%s.%s" % (key, host)
        if not self.redis.expire(topic, CONF.matchmaker_heartbeat_ttl):
            # If we could not update the expiration, the key
            # might have been pruned. Re-register, creating a new
            # key in Redis.
            self.register(self.host_topic[host], host)

    self.host_topic is a dict with keys of tuple (key, host), not 'host',
    register's first parameter is the topic like 'notification-info',
    so modify it to key.
    And it will not cause indefinite recursion, because when register end,
    the key exist in redis, redis.expire will return True.

    Add test case for ack_alive.

    Closes-Bug: #1419718

    Change-Id: I8d972afe89aec02a5c8f0d9dd4e216bc12c298a1

Changed in oslo.messaging:
status: In Progress → Fix Committed
Changed in oslo.messaging:
milestone: none → 1.8.0
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.