Bug 731043

Summary: timeout waiting for sync
Product: Red Hat Enterprise MRG Reporter: Petr Matousek <pematous>
Component: qpid-javaAssignee: Rajith Attapattu <rattapat+nobody>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Matousek <pematous>
Severity: high Docs Contact:
Priority: high    
Version: 2.0CC: iboverma, jross, lzhaldyb
Target Milestone: 2.3   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qpid-java-*-0.18-5 Doc Type: Bug Fix
Doc Text:
Cause: delete for addressing does not work correctly. it also appears that the delete was send for a queue instead of the exchange. Consequence: Client hangs due to waiting for a command completion on a session which was invalidated due to an exception. It eventually times out. Fix: Delete is only sent if the session is still valid. Result: The client will not hang anymore. However it will not issue a delete if the session is closed before the producer/consumer is closed. It's recommended and good practise to first close the producers and consumers before closing the session (all though the session close should implicitly close producers and consumers). The ordered closing allows the JMS client to cleanup the resources correctly.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-19 16:40:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Matousek 2011-08-16 14:55:21 UTC
Description of problem:

By executing the following command:

# java -cp $CLASSPATH org.apache.qpid.example.Spout "ex;{ create:sender, delete: sender, node: {type:topic,x-declare:{type:direct}}}"

firstly, it seems that the program hangs. After a while (~1 min) the programs ends execution with following exception:

<snip>
org.apache.qpid.AMQException: timed out waiting for sync: complete = 0, point = 2 [error code 541: internal error]
</snip>

Moreover exception "Delete failed. No such queue" is thrown, which is not true.
(The exchange is created, message is sent to that exchange, but the issue occurs on exchange deletion)

The issue occurs also while trying to delete already existing exchange using addressing - please see additional info

--

The behaviour is quite similar to Bug 698657, this issue can be closed as duplicate if determined that this is invoked by the same root cause.
BUT adding the delay to the test code do not solve this issue.
please see:
https://issues.apache.org/jira/browse/QPID-3259?focusedCommentId=13036452&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13036452

Version-Release number of selected component (if applicable):
qpid-java-0.10-6

How reproducible:
100%

Steps to Reproduce:
1. java -cp $CLASSPATH org.apache.qpid.example.Spout "ex;{ create:sender, delete: sender, node: {type:topic,x-declare:{type:direct}}}"
2. it seems to the program hangs, wait a bit more time
3. exception occurs
  
Actual results:
firstly, it seems that the program hangs. After a while (~1 min) the programs ends execution with an exception.

Expected results:
Exchange can be deleted using addressing.

Using the command above:
The exchange is created by the sender, message is sent to that exchange, the exchange is removed by the sender when the link ends.


Additional info:

The issue occurs also while trying to delete already existing exchange using following code:

# qpid-config add exchange direct ex2
# java -cp $CLASSPATH org.apache.qpid.example.Spout "ex2;{ delete: sender}
{}

------------- Msg -------------
Body:

JMS Correlation ID: null
JMS timestamp: 1313507900947
JMS expiration: 0
JMS priority: 4
JMS delivery mode: 2
JMS reply to: null
JMS Redelivered: false
JMS Destination: 'ex2'/None; {
  'delete': 'sender',
  'node': {
    'type': 'topic'
  }
}
JMS Type: null
JMS MessageID: ID:ab82c6c1-802b-32af-96e8-7dcc5f197d9f
JMS Content-Type: text/plain
AMQ message number: -1
Properties:
	qpid.subject = 

-------------------------------

main 2011-08-16 17:19:30,964 ERROR [apache.qpid.client.AMQConnection] Throwable Received but no listener set: org.apache.qpid.AMQException: timed out waiting for sync: complete = 0, point = 2 [error code 541: internal error]
IoReceiver - localhost/127.0.0.1:5672 2011-08-16 17:19:30,966 ERROR [apache.qpid.client.AMQConnection] Throwable Received but no listener set: org.apache.qpid.AMQException: ch=0 id=1 ExecutionException(errorCode=NOT_FOUND, commandId=2, classCode=8, commandCode=2, fieldIndex=0, description=not-found: Delete failed. No such queue:  (qpid/broker/Broker.cpp:821), errorInfo={}) [error code 404: not found]
IoReceiver - localhost/127.0.0.1:5672 2011-08-16 17:19:30,967 WARN [apache.qpid.transport.SessionDelegate] CLOSED: [ssn:"5bd39826-341a-4ba8-925d-7ea65f870300"]
Exception in thread "main" javax.jms.JMSException: Error closing session: org.apache.qpid.AMQException: timed out waiting for sync: complete = 0, point = 2 [error code 541: internal error]
	at org.apache.qpid.client.AMQSession.close(AMQSession.java:748)
	at org.apache.qpid.client.AMQSession.close(AMQSession.java:708)
	at org.apache.qpid.client.AMQSession.close(AMQSession.java:567)
	at org.apache.qpid.example.Spout.<init>(Spout.java:105)
	at org.apache.qpid.example.Spout.main(Spout.java:148)
Caused by: org.apache.qpid.AMQException: timed out waiting for sync: complete = 0, point = 2 [error code 541: internal error]
	at org.apache.qpid.client.AMQSession_0_10.setCurrentException(AMQSession_0_10.java:1031)
	at org.apache.qpid.client.AMQSession_0_10.sendClose(AMQSession_0_10.java:396)
	at org.apache.qpid.client.AMQSession.close(AMQSession.java:742)
	... 4 more
IoReceiver - localhost/127.0.0.1:5672 2011-08-16 17:19:30,970 WARN [apache.qpid.transport.SessionDelegate] CLOSED: [ssn:"5bd39826-341a-4ba8-925d-7ea65f870300"]

Comment 2 Petr Matousek 2012-11-21 09:55:07 UTC
This issue has been fixed.

Verified on rhel5.8 and rhel6.3 (x86_64, i386)

packages used for testing:
qpid-java-*-0.18-5

-> VERIFIED

Comment 3 Rajith Attapattu 2012-12-13 15:50:50 UTC
Petr,

(Sorry I was on vacation and somehow missed this when I came back).

I made changes to the address handling code which fixed a lot of minor bugs, especially the way we handled delete. It's a series of commits included in the 0.20 rebase.

Delete is a tricky issue that cannot be completely fixed (true for all clients and JMS client has a few additional complications). For complications please see the comments on https://bugzilla.redhat.com/show_bug.cgi?id=876192

The following commit is largely responsible for this issue being fixed.
http://svn.apache.org/viewvc?rev=1397651&view=rev

Additionally we have also made changes during the last few cycles to error handling code.

Rajith