Bug 743100

Summary: msgGroups: broker crash when purge/reroute method called for more messages than queue actual messages count
Product: Red Hat Enterprise MRG Reporter: Petr Matousek <pematous>
Component: qpid-cppAssignee: Ken Giusti <kgiusti>
Status: CLOSED CURRENTRELEASE QA Contact: MRG Quality Engineering <mrgqe-bugs>
Severity: unspecified Docs Contact:
Priority: high    
Version: DevelopmentCC: jross
Target Milestone: 2.1.2   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause Attempting to purge or move more messages than are present on a message group queue. Consequence The broker will crash. Fix The broker will check if the requested number of messages is present. Result If there are less than the requested number of messages present on the queue, the broker will only move/purge those messages that are present.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
test reproducer
none
stack trace
none
stack_trace2.txt none

Description Petr Matousek 2011-10-03 20:19:18 UTC
Description of problem:

For the queues defined with the message groups functionality enabled (qpid.group_header_key supplied):
If requested to purge/reroute more than actual messages count in the
non-empty queue (either using qpid-tool or qmf), broker connection is
aborted.

qpidd: ./qpid/broker/MessageGroupManager.h:73: void qpid::broker::MessageGroupManager::unFree(const qpid::broker::MessageGroupManager::GroupState&): Assertion `pos != freeGroups.end() && pos->second == &state' failed.
Exception in do_call: %r (None, 'connection aborted')
qpid: Broker disconnected: Disconnected Broker

The stack trace is attached and contains following error:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb6 in position 3: unexpected code byte

Please see additional info for more details,

Version-Release number of selected component (if applicable):
qpidd (qpidc) version 0.13
snv branch QPID-3346 (revision 1177617)

How reproducible:
100%

Steps to Reproduce:
1. run the attached test reproducer
  
Actual results:
abort signal on the broker when purge/reroute more messages than actual messages count in the queue

Expected results:
purge/reroute all the messages matching the filter

Additional info:

Moreover consuming messages after "successful" command call (queue contains more messages than requested) leads again to core dump.
The stack trace is attached - stack_trace2.txt.

this can be reproduced using the following change in attached test reproducer:
- result = q.purge(5, {})
+ result = q.purge(1, {})

Comment 1 Petr Matousek 2011-10-03 20:21:35 UTC
Created attachment 526125 [details]
test reproducer

Comment 2 Petr Matousek 2011-10-03 20:34:15 UTC
Created attachment 526128 [details]
stack trace

Comment 3 Petr Matousek 2011-10-03 20:34:45 UTC
Created attachment 526130 [details]
stack_trace2.txt

Comment 4 Ken Giusti 2011-11-02 20:14:26 UTC
Should be fixed as of upstream revision: 1196764

Comment 5 Petr Matousek 2012-01-17 14:39:48 UTC
This issue has been fixed.

Verified on RHEL5.7 and RHEL6.2, architectures: x86_64, i686 

packages installed:
qpid-cpp-mrg-0.14-3.el5
qpid-qmf-0.14-2.el5
qpid-cpp-0.14-1.el6
qpid-qmf-0.14-3.el6

-> VERIFIED

Comment 6 Ken Giusti 2012-03-07 21:52:23 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause
    Attempting to purge or move more messages than are present on a message group queue.
Consequence
    The broker will crash.
Fix
    The broker will check if the requested number of messages is present.
Result
    If there are less than the requested number of messages present on the queue, the broker will only move/purge those messages that are present.