rabbitmq / rabbitmq/rabbitmq-java-client
Thread.interrupt() cause message loss and hang for ChannelRpcTimeout(default 10mins) or forever
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.3k
- Forks
- 587
- Avg merge
- 7h 29m
- Merged PRs (30d)
- 41
Description
To avoid thread execution for too long, we interrupt the thread after the time limit is reached. Recently, We find that occasionally messages get lost. We use TX mode , and txCommit() got an ChannelContinuationTimeoutException. I found the following problem according to the warning log.
if thread interrupted before rpc(m,k) then rpc will not be sent to the server. And k.getReply(..) will hang for _rpcTimeout or forever.
client version is 5.8.0
com.rabbitmq.client.impl.AMQChannel
private AMQCommand privateRpc(Method m)
throws IOException, ShutdownSignalException
{
SimpleBlockingRpcContinuation k = new SimpleBlockingRpcContinuation(m);
rpc(m, k);
// At this point, the request method has been sent, and we
// should wait for the reply to arrive.
//
// Calling getReply() on the continuation puts us to sleep
// until the connection's reader-thread throws the reply over
// the fence or the RPC times out (if enabled)
if(_rpcTimeout == NO_RPC_TIMEOUT) {
return k.getReply();
} else {
try {
return k.getReply(_rpcTimeout);
} catch (TimeoutException e) {
throw wrapTimeoutException(m, e);
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in com.rabbitmq.client.impl.AMQChannel, especially privateRpc(), rpc(m,k), and getReply(...), and reproduce the interruption path described in the warning log using the 5.8.0 client. Done means the interrupted call no longer loses the message or leaves getReply hanging beyond the configured timeout; add or update a regression test if the repository provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, rabbitmq
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100