-
Notifications
You must be signed in to change notification settings - Fork 584
Exponential backoff for recovery retry interval #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@vikinghawk Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@vikinghawk Thank you for signing the Contributor License Agreement! |
for (String consumerTag : consumerTags) { | ||
this.connection.deleteRecordedConsumer(consumerTag); | ||
} | ||
// TODO what about any other recorded queues and bindings that were owned by this channel? They will now cause recovery exceptions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Queues and bindings are not "owned" by channels in any way. Consumers are channel state, however. Queues and bindings are tracked by connections (in part because queues can be owned by connections — when they are exclusive — and in part because declaring something on one channel then deleting it on another should leave no traces of that entity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya thats a bad description. What that is referencing is that any queues or bindings that were created with this channel still have the recorded entities reference this now closed channel and will throw an exception during recovery. I don't know a good way to address this other than having recorded queues/exchanges/bindings use a special "recovery" channel instead of the original creating channel. I assume the only recorded items that would require to be tied to the original channel that created them would be consumers which are cleaned up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this change.
this.connection.deleteRecordedConsumer(consumerTag); | ||
} | ||
this.connection.unregisterChannel(this); | ||
recoveryCleanup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change really related to delay calculation and back-off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, just noticed the recorded consumers weren't being deleted with the 2nd close method like the 1st. These were some changes i had stashed in my repo from looking at some other stuff and got included here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed for now. could be a separate future PR
In general this looks promising. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please polish as you suggested (Javadoc, etc) and address Michael's comments. Thanks!
Updated with javadoc, test, and suggested changes. |
@@ -541,8 +542,7 @@ private RecoveryAwareAMQConnection recoverConnection() throws InterruptedExcepti | |||
newConn.abort(); | |||
return null; | |||
} catch (Exception e) { | |||
// TODO: exponential back-off | |||
Thread.sleep(this.params.getNetworkRecoveryInterval()); | |||
Thread.sleep(this.params.getRecoveryDelayHandler().getDelay(attempts)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on flipping the order of these 2 lines? Should it be delivering the exception before sleeping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it the way it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I think at some point we will have to do it. The way it works right now is a bit weird and can complicate additional manual recovery steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@@ -541,8 +542,7 @@ private RecoveryAwareAMQConnection recoverConnection() throws InterruptedExcepti | |||
newConn.abort(); | |||
return null; | |||
} catch (Exception e) { | |||
// TODO: exponential back-off | |||
Thread.sleep(this.params.getNetworkRecoveryInterval()); | |||
Thread.sleep(this.params.getRecoveryDelayHandler().getDelay(attempts)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it the way it is.
Isssue #308
First stab at a pluggable recovery retry interval and basic fibonnaci backoff implementation. Let me know your thoughts and i can make changes and add javadoc if this seems like something you guys like.