-
Notifications
You must be signed in to change notification settings - Fork 17
Conversation
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.
shouldn't we do this in upsert
too?
Ah yeah, too recent. |
Fixed. |
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.
Maybe it make sense to treat them as regular tags and not prune them.
Alternatively, we could change the semantics and say that all tags persist even after closing the connection for some grace period. garbage collecting tags for disconnected peers periodically. This will likely have little overhead and may make some things more predictable. For example, I believe it's possible for the connection manager to see a peer disconnect while a different service doesn't (if we get a simultaneous disconnect+connect). |
Hm, that would be valuable in an intermittent disconnection + reconnection. However, I think it's confusing because most protocols are designed to entirely drop internal state when a peer disconnects, and reconstruct it starting from scratch when it reconnects. Or do any protocols keep a "ghost" state? Honestly I think it could cause more problems than advantages. |
In fact, we have nothing in the system that will try to re-establish a lost connection automatically. The reconnection is always triggered by a protocol. |
My main concern is that not all services will necessarily see the disconnect. They'll see the connection drop but services usually only drop state when all connections drop. At the moment, this will leave untagged peers. However, I agree that a grace period like that would be kind of weird. What if we never GC tags? That is, we independently track tags/connections and expect services to remove tags when they no longer need a peer. As far as I can tell, almost all of our services correctly do this anyways. IMO, that's the least surprising way to handle this given that we assign weights to peers and not individual connections. |
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.
small nits you can ignore
Do not merge yet, there is a race with decremented tags on upsert that can be triggered by relay code. Suggested change: Either don't create temporary tags on upsert or ignore tags with negative values. |
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.
See #39 (comment)
@vyzo – based on the last comment, it seems the semantics of |
@vyzo bump. |
I don't like the idea of renaming the |
I propose to merge this as it respects the semantics of Upsert. We might want an Update method that strictly updates the peer if and only if a previous tag exists. |
Discussed out of band and decided then problem is in the Upsert semantics.
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.
I have update the callsites to Upsert
to not decrement a 0 tag, which resolves the pathology.
An Update
method, companion to Upsert
, sounds fine.
this will need rebase; let me know if you think a review is needed post rebase. |
A patch I had cooked up a while ago and forgot to submit.
Occasionally protocols try to tag peers in the connection manager before the latter has learnt about the connection via the
Connected
callback.This patch buffers such tags in temporary entries. Such entries are safeguarded during the grace period, and once this period has elapsed, they take precedence for pruning. Hence they don't build up over time and drift away automatically.