-
Notifications
You must be signed in to change notification settings - Fork 184
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
feat(sync): track incoming sync requests, allow subscriptions without sync, close inactive replicas #1491
Conversation
982263b
to
d92142b
Compare
065a002
to
ff8425c
Compare
|namespace, _| { | ||
futures::future::ready( | ||
bob_replica_store_task | ||
.open_replica(&namespace) |
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.
this is a blocking call, we should probably mark it as such
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.
deferred for later: #1502
&mut bob_writer, | ||
&mut bob_reader, | ||
bob_store, | ||
|namespace, _| { | ||
futures::future::ready(bob_store.open_replica(&namespace).map(Into::into)) |
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.
same 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.
deferred to #1502
…ve sync (#1495) ## Description Based on #1491 This adds two related features that were missing so far: * Add `iroh_sync::store::close_replica` to remove a replica instance from the store-internal cache of open replicas. This is needed because otherwise it grows unbounded (for anchor nodes especially). * Properly handle open replicas in the `LiveSync`, and through this allow to subscribe to replica events for replicas that are not in the set of actively syncing replicas. This was not possible before (you could only subscribe to replicas that are active for sync) * Add test for subscribing without sync ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [x] Tests if relevant.
## Description On `main` the test `sync_full_basic` is flakey. This PR (hopefully) fixes it. The reason was: We have the situation that two peers initiate connections to each other at (roughly) the same time. In #1491 this was sometimes prevented, but not reliably. This PR fixes it by: * When connecting, we set a `SyncState::Dialing` for the `(namespace, peer)` * When accepting, if our own state is `Dialing` for the incoming request for `(namespace, peer)` we compare our peer id with that of the incoming request, and abort if ours is higher (doesn't matter which way, we care about a predictable outcome only * Through this, only one of the two simoultanoues connections will survive * Also added a `Abort` frame to the wire protocol to transfer to inform the dialer about the reason of the declined request, which is either "we do double sync, and will take the other conn" (`AlreadySyncing`) or "this replica is not here" (`NotAvailable`) This PR also: * Further improves logging * Improves errors ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [x] Tests if relevant. --------- Co-authored-by: Diva M <divma@protonmail.com>
Description
This PR adds a few missing parts for sync in iroh:
LiveSync
and close them once they're not needed anymore. Therefore addsiroh_sync::store::close_replica
to remove a replica instance from the store-internal cache of open replicas. This is needed because otherwise it grows unbounded (for anchor nodes especially).LiveSync
actor and handle them there. Before, incoming connections for sync were always processed if a replica with the requestedNamespaceId
is found in the local replica store. This PR changes this mechanism so that incoming sync connections are passed into the sync engine first. This leads to the changes that motivate this PR:start_sync
). Note that this is not persisted at the moment, but should be (separate change though).LiveEvent:.SyncFinished
that reports all available informationNotes & open questions
Do we want to track history of syncs internally or leave it up to the app via the events? Not sure myself.
The diff of
sync_engine/live.rs
is a little hard to read, because there's a change fromTopicId
toNamespaceId
in a few places that is mostly unrelated. Sorry for the mixup, but it makes sense to track everything byNamespaceId
and it ended up in a commit here.Logging is much improved in this PR.
Maybe we can improve the code flow a little to make things more obvious.
Change checklist