Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Bail early if remote wouldn't be retried #2064

Merged
merged 4 commits into from
Mar 29, 2017
Merged

Conversation

erikjohnston
Copy link
Member

No description provided.


if retry_last_ts + retry_interval > now:
defer.returnValue(True)
defer.returnValue(True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be missing a False case.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few thoughts and grumblings.

@@ -35,6 +35,29 @@ def __init__(self, retry_last_ts, retry_interval, destination):


@defer.inlineCallbacks
def would_retry(destination, clock, store):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this is a bit of a funny name, when it is equally applicable to the very first message we send to a destination (so in no way a 'retry'). Maybe would_send would be better? Or would_throw_on_send (and invert the result). Neither is particularly great though - I don't mind if you want to leave it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course another way to do this is just to call get_retry_limiter, and throw away the result, and see if you get an exception.

def would_retry(destination, clock, store):
"""Check if ``get_retry_limiter`` would throw. This is purely to allow
things to bail early if the resulting request would not otherwise be sent
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please can we document types of args and return values, even if it's "obvious". I'm fed up with figuring it all out from first principles in the synapse codebase. You can even c&p most of it from get_retry_limiter in this case.

try:
self.pending_transactions[destination] = 1

if not (yield would_retry(destination, self.clock, self.store)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given we logger.debug when we get a NotRetryingDestination exception (a block of code which is now almost redundant, btw), should we do so here? should we in fact throw a NotRetryingDestination here?

@richvdh richvdh assigned erikjohnston and unassigned richvdh Mar 29, 2017
@erikjohnston
Copy link
Member Author

You raise excellent points.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much better

suggest squash-merging this, the history doesn't seem useful.

try:
self.pending_transactions[destination] = 1

# This will throw if we woldn't retry. We do this here so we fail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woldn't

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants