Issue Details (XML | Word | Printable)

Key: AMQ-1779
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Rob Davies
Reporter: Kai Hudalla
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ActiveMQ

RA does not reconnect correctly to a failed broker

Created: 06/Jun/08 06:59 AM   Updated: 06/Jun/08 11:59 AM
Return to search
Component/s: Connector
Affects Version/s: 5.0.0, 5.1.0
Fix Version/s: 5.2.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works amq-1779.patch 2008-06-06 07:22 AM Kai Hudalla 24 kB
Issue Links:
Related
 

Patch Info: Patch Available


 Description  « Hide
The Resource Adapter does not cleanly reconnect to a failed broker:
  • it uses stale sessions to deliver messages to an Endpoint resulting in messages not being delivered at all anymore after the connection has been re-established
  • the code for connecting/reconnecting to the broker is not synchronized properly leading to race conditions/deadlocks in some situations

Kai



 All   Comments   Work Log   Change History   Subversion Commits   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Kai Hudalla made changes - 06/Jun/08 07:15 AM
Field Original Value New Value
Link This issue is related to AMQ-1632 [ AMQ-1632 ]
Kai Hudalla added a comment - 06/Jun/08 07:15 AM - edited
The work done by David Jencks on the 4.x branch in AMQ-1632 still has some issues regarding synchronization:
  • When the RA tries to connect to the broker, it does so by subsequently scheduling the connectWork using the WorkManager. However, the monitor on connectWork may be lost when the connectWork is re-scheduled after an unsuccessful attempt, making it possible that the getConnection() method gets the monitor and returns null instead of the re-established connection.
  • The code for registering a ConnectionConsumer on the ActiveMQConnection leads to a deadlock if there are some messages left to be delivered from before the broker has failed. In that case, the ServerSessionPoolImpl.createServerSessionImpl() method will be triggered by the next message delivery. However, the createServerSessionImpl() method needs to wait for the EndpointWorker.getConnection() method to return which is also synchronized on the connectWork that is trying to register the ConnectionConsumer. The problem here is that the constructor of the ActiveMQConnectionConsumer uses syncSendPacket() instead of asyncSendPacket() in order to register the consumer with the broker. Thus the instantiation of the ActiveMQConnectionConsumer blocks until the first message has been delivered, leading to the deadlock.

Kai


Kai Hudalla added a comment - 06/Jun/08 07:22 AM
I have changed the connectWork to loop until it finally gets a connection to the broker instead of re-scheduling itself after a failed connection attempt. This way, the monitor on connectWork is kept until the connection succeeds. In order to make this work, the ActiveMQConnectionConsumer needs to use asyncSendPacket() for registering itself with the consumer to avoid a deadlock on the connectWork.

The patch also includes David's fix for the prefetchSize calculation in the EndpointWorker.

Kai


Kai Hudalla made changes - 06/Jun/08 07:22 AM
Attachment amq-1779.patch [ 16539 ]
664079 by  Rob Davies (1 file)
06/Jun/08 11:56 AM (17 months, 11 days ago)
Repository Revision Date User Message
AMQ #664079 Fri Jun 06 11:56:02 PDT 2008 rajdavies patch for https://issues.apache.org/activemq/browse/AMQ-1779
Files Changed
MODIFY /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionConsumer.java

Rob Davies made changes - 06/Jun/08 11:59 AM
Assignee Rob Davies [ rajdavies ]
Repository Revision Date User Message
AMQ #664082 Fri Jun 06 11:59:11 PDT 2008 rajdavies patch for https://issues.apache.org/activemq/browse/AMQ-1779
Files Changed
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQEndpointWorker.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageResourceAdapter.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java

Rob Davies added a comment - 06/Jun/08 11:59 AM
Patch applied by SVN revision 664079 and 664082

Rob Davies made changes - 06/Jun/08 11:59 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Fix Version/s 5.2.0 [ 11841 ]
Create crucible review for all 2 changesets in