Bug 682877

Summary: Producer flow control - qpidd allows queue creation with invalid flow arguments
Product: Red Hat Enterprise MRG Reporter: ppecka <ppecka>
Component: qpid-cppAssignee: Ken Giusti <kgiusti>
Status: CLOSED CURRENTRELEASE QA Contact: MRG Quality Engineering <mrgqe-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.3CC: kgiusti
Target Milestone: 2.0   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
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
reproduce with "OLD API" none

Description ppecka 2011-03-07 20:48:55 UTC
Description of problem:
Attempt to create queue with invalid flow parameters ( in this case any "resume" value is greater than appropriate "stop" value) lets client (qpid-config) to create such queue.

arguments  {u'qpid.flow_stop_size': 5000L, u'qpid.flow_stop_count': 200L, u'qpid.flow_resume_size': 6000L, u'qpid.flow_resume_count': 33300L}


Version-Release number of selected component (if applicable):
#rpm -qa | grep qpid | sort -u
python-qpid-0.9.1073306-1.el5
qpid-cpp-client-0.9.1073306-1.el5
qpid-cpp-client-devel-0.9.1073306-1.el5
qpid-cpp-client-devel-docs-0.9.1073306-1.el5
qpid-cpp-client-ssl-0.9.1073306-1.el5
qpid-cpp-server-0.9.1073306-1.el5
qpid-cpp-server-cluster-0.9.1073306-1.el5
qpid-cpp-server-devel-0.9.1073306-1.el5
qpid-cpp-server-ssl-0.9.1073306-1.el5
qpid-cpp-server-store-0.9.1073306-1.el5
qpid-cpp-server-xml-0.9.1073306-1.el5
qpid-java-client-0.9.1073306-1.el5
qpid-java-common-0.9.1073306-1.el5
qpid-java-example-0.9.1073306-1.el5
qpid-tools-0.9.1073306-1.el5
rh-qpid-cpp-tests-0.9.1073306-1.el5


How reproducible:
100%

Steps to Reproduce:
1. reproducer attached
  
Actual results:
Queue created with invalid parametrs - even it raises error
Failed: SessionException: ExecutionException(error_code=542, command_id=serial(73), class_code=8, command_code=1, field_index=0, description=u'invalid-argument: Queue "182744": qpid.flow_resume_count=33300 must be less than qpid.flow_stop_count=200 (qpid/broker/QueueFlowLimit.cpp:50)', error_info={}, channel=1, id=serial(77))


from qpid-tool
arguments  {u'qpid.flow_stop_size': 5000L, u'qpid.flow_stop_count': 200L, u'qpid.flow_resume_size': 6000L, u'qpid.flow_resume_count': 33300L}

Expected results:
Queue is not created OR wrong settings are overwritten with defaults


Additional info:

Comment 1 Ken Giusti 2011-03-15 20:56:35 UTC
Hi, 

Can you reproduce this, and double-check the output in qpid-tool?

When I try to reproduce this, it appears as if the queue does not exist.

The queue is listed in qpid-tool, but it is marked as "Deleted" - the "Destroyed" timestamp is set.

For example, if I do:

 qpid-config add queue ken01 --flow-stop-count=100 --flow-resume-count=10000

and then check qpid-tool:

qpid: list queue
Object Summary:
    ID   Created   Destroyed  Index
    ========================================================================
    123  19:49:16  -          135.qmfc-v2-hb-localhost.localdomain.26266.1
    124  19:49:16  -          135.qmfc-v2-localhost.localdomain.26266.1    
       <snip>
    171  19:52:48  19:52:48   135.ken01
-------------------^^^^^^^^^^^^^^^^^^^^

It shows that the queue no longer exists.  The reason it shows up as created is that the broker first creates the queue object, then attempts to configure it based on the input parameters.  If the configuration is invalid, the broker will then remove the queue.  This results in the queue appearing in qpid-tool.  

I've also tried another way to create a queue using bad parameters:

 qpid-config add queue ken05 --max-queue-size=-1

This also results in a destroyed "ken05" queue showing up in qpid-tool:

    ID   Created   Destroyed  Index
    ========================================================================
    123  19:49:16  -          135.qmfc-v2-hb-localhost.localdomain.26266.1
    124  19:49:16  -          135.qmfc-v2-localhost.localdomain.26266.1
    125  19:49:16  -          135.qmfc-v2-ui-localhost.localdomain.26266.1
    126  19:49:16  -          135.reply-localhost.localdomain.26266.1
    127  19:49:16  -          135.topic-localhost.localdomain.26266.1
     <snip>
    171  19:52:48  19:52:48   135.ken01
     <snip>
    301  20:44:19  20:44:19   135.ken05
 
qpid-tool will save information about queues that have been deleted.  The "qpid-stat -q" tool only shows those queue that are operational - can you try "qpid-stat -q" in your testcase?  When I do, the deleted queues do no show up.

thanks,

-K

Comment 2 ppecka 2011-03-16 14:34:02 UTC
(In reply to comment #1)
if new API address is used, then i can confirm it works exactly as you've described - this is ok.
if an old api is used (queue is created over qpid-config) this is seen on configured queue, after messages were sent and read from it. see attachment

org.apache.qpid.broker
  queue
    queue (0-1114-1-0-org.apache.qpid.broker:queue:queue)
      name	queue
      durable	False
      autoDelete	False
      exclusive	False
      arguments	{u'qpid.flow_stop_size': 6000L, u'qpid.flow_stop_count': 600L, u'qpid.flow_resume_size': 10000L, u'qpid.flow_resume_count': 1000L}
      msgTotalEnqueues	610
      msgTotalDequeues	610
      ...
      msgDepth	0
      byteDepth	0
      byteTotalEnqueues	6100
      byteTotalDequeues	6100
      ...
      flowStopped	False
      purge(request)	Discard all or some messages on a queue
      reroute(request ,useAltExchange ,exchange)	Remove all or some messages on this queue and route them to an exchange

Comment 3 ppecka 2011-03-16 14:37:28 UTC
Created attachment 485754 [details]
reproduce with "OLD API"

Comment 4 Ken Giusti 2011-03-16 17:29:22 UTC
Thank you for the reproducer script.

I've run the script against a broker running on RHEL5 (x86_64) (qpid-cpp-server-0.9.1079953-1.el5, rh-qpid-cpp-tests.0.9.1079953-1), trying both "OLD" and "NEW" api options, but this still fails to create a queue.  The output from running the script is:


API=OLD:
[kgiusti@localhost Downloads]$ API=OLD ./simple_reproducer.sh
+ [[ OLD =~ OLD ]]
+ SEND_ADDR='exchange/bkey;'
+ qpid-config -a 192.168.122.147:5672 add exchange topic exchange
+ qpid-config -a 192.168.122.147:5672 add queue queue --flow-stop-size=6000 --flow-resume-size=10000 --flow-stop-count=600 --flow-resume-count=1000
Failed: SessionException: ExecutionException(error_code=542, command_id=serial(65), class_code=8, command_code=1, field_index=0, description=u'invalid-argument: Queue "queue": qpid.flow_resume_count=1000 must be less than qpid.flow_stop_count=600 (qpid/broker/QueueFlowLimit.cpp:50)', error_info={}, channel=1, id=serial(62))
+ qpid-config -a 192.168.122.147:5672 bind exchange queue bkey
Failed: SessionException: ExecutionException(error_code=404, command_id=serial(66), class_code=7, command_code=4, field_index=0, description=u'not-found: Bind failed. No such queue: queue (qpid/broker/Broker.cpp:925)', error_info={}, channel=1, id=serial(63))
+ qpid-send --broker 192.168.122.147:5672 --address 'exchange/bkey;' --messages 600 --content-size 10 --capacity 1
+ sleep 2
+ qpid-send --broker 192.168.122.147:5672 --address 'exchange/bkey;' --messages 10 --content-size 10 --capacity 1
+ qpid-stat -q 192.168.122.147:5672
+ grep queue
  queue                                     dur  autoDel  excl  msg   msgIn  msgOut  bytes  bytesIn  bytesOut  cons  bind
+ grep queue
+ qpid-config -a 192.168.122.147:5672 queues
+ qpid-receive --broker 192.168.122.147:5672 --address queue
+ wc -l
2011-03-16 13:16:26 warning Exception received from broker: not-found: not-found: Queue not found: queue (qpid/broker/SessionAdapter.cpp:686) [caused by 2 \x08:\x01]
Failure: Queue queue does not exist
0
+ set +x


API=NEW:
[kgiusti@localhost Downloads]$ API=NEW ./simple_reproducer.sh
+ [[ NEW =~ OLD ]]
+ qpid-send --broker 192.168.122.147:5672 --address 'queue/bkey; {create: always, node:{ x-declare :{arguments :{ qpid.flow_stop_size: 6000L,  qpid.flow_resume_size: 10000L,  qpid.flow_stop_count: 600L,  qpid.flow_resume_count: 1000L, }}}}' --messages 600 --content-size 10 --capacity 1
2011-03-16 13:15:26 warning Exception received from broker: invalid-argument: invalid-argument: Queue "queue": qpid.flow_resume_count=1000 must be less than qpid.flow_stop_count=600 (qpid/broker/QueueFlowLimit.cpp:50) [caused by 2 \x08:\x01]
Failed: invalid-argument: invalid-argument: Queue "queue": qpid.flow_resume_count=1000 must be less than qpid.flow_stop_count=600 (qpid/broker/QueueFlowLimit.cpp:50)
+ sleep 2
+ qpid-send --broker 192.168.122.147:5672 --address 'queue/bkey; {create: always, node:{ x-declare :{arguments :{ qpid.flow_stop_size: 6000L,  qpid.flow_resume_size: 10000L,  qpid.flow_stop_count: 600L,  qpid.flow_resume_count: 1000L, }}}}' --messages 10 --content-size 10 --capacity 1
2011-03-16 13:15:26 warning Exception received from broker: invalid-argument: invalid-argument: Queue "queue": qpid.flow_resume_count=1000 must be less than qpid.flow_stop_count=600 (qpid/broker/QueueFlowLimit.cpp:50) [caused by 2 \x08:\x01]
Failed: invalid-argument: invalid-argument: Queue "queue": qpid.flow_resume_count=1000 must be less than qpid.flow_stop_count=600 (qpid/broker/QueueFlowLimit.cpp:50)
+ qpid-stat -q 192.168.122.147:5672
+ grep queue
  queue                                     dur  autoDel  excl  msg   msgIn  msgOut  bytes  bytesIn  bytesOut  cons  bind
+ qpid-config -a 192.168.122.147:5672 queues
+ grep queue
+ qpid-receive --broker 192.168.122.147:5672 --address queue
+ wc -l
2011-03-16 13:15:33 warning Exception received from broker: not-found: not-found: Queue not found: queue (qpid/broker/SessionAdapter.cpp:686) [caused by 2 \x08:\x01]
Failure: Queue queue does not exist
0
+ set +x

Both fail to create the queue as described.   Would it be possible for me to try debugging this using the system you can cause this problem on?

Comment 5 ppecka 2011-03-17 17:41:05 UTC
 i'm seeing it on my i386 / rhel 5.6 virtual machine


rpm -qa | grep qpid
qpid-cpp-client-ssl-0.9.1073306-1.el5
qpid-cpp-client-devel-docs-0.9.1073306-1.el5
rh-qpid-cpp-tests-0.9.1073306-1.el5
qpid-cpp-client-devel-0.9.1073306-1.el5
qpid-cpp-server-store-0.9.1073306-1.el5
qpid-java-example-0.9.1073306-1.el5
qpid-cpp-server-xml-0.9.1073306-1.el5
qpid-cpp-server-cluster-0.9.1073306-1.el5
qpid-cpp-server-devel-0.9.1073306-1.el5
qpid-tools-0.9.1073306-1.el5
qpid-java-common-0.9.1073306-1.el5
qpid-cpp-client-0.9.1073306-1.el5
qpid-cpp-server-ssl-0.9.1073306-1.el5
python-qpid-0.9.1073306-1.el5
qpid-java-client-0.9.1073306-1.el5
qpid-cpp-server-0.9.1073306-1.el5

Comment 6 ppecka 2011-03-24 10:12:01 UTC
I'm not observing issue on any supported RHEL since this package set


rpm -qa | grep qpid | sort -u
python-qpid-0.9.1079482-1.el5
python-qpid-qmf-0.9.1079953-3.el5
qpid-cpp-client-0.9.1079953-1.el5
qpid-cpp-client-devel-0.9.1079953-1.el5
qpid-cpp-client-devel-docs-0.9.1079953-1.el5
qpid-cpp-client-ssl-0.9.1079953-1.el5
qpid-cpp-mrg-debuginfo-0.9.1079953-1.el5
qpid-cpp-server-0.9.1079953-1.el5
qpid-cpp-server-cluster-0.9.1079953-1.el5
qpid-cpp-server-devel-0.9.1079953-1.el5
qpid-cpp-server-ssl-0.9.1079953-1.el5
qpid-cpp-server-store-0.9.1079953-1.el5
qpid-cpp-server-xml-0.9.1079953-1.el5
qpid-java-client-0.9.1080013-2.el5
qpid-java-common-0.9.1080013-2.el5
qpid-java-example-0.9.1080013-2.el5
qpid-qmf-0.9.1079953-3.el5
qpid-qmf-devel-0.9.1079953-3.el5
qpid-tools-0.9.1078967-1.el5
rh-qpid-cpp-tests-0.9.1079953-1.el5