-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(storage-manager): initial alignment on empty Storage
This commit changes the way a replicated Storage starts: if it is empty and configured to be replicated, it will attempt to align with an active and compatible (i.e. same configuration) Replica before anything. The previous behaviour made a query on the key expression of the Storage. Although, it could, in some cases, actually perform the same initial alignment, it could not guarantee to only query a Storage that was configured to be replicated. To perform this controlled initial alignment, new variants to the `AlignmentQuery` and `AlignmentReply` enumerations were added: `Discovery` to discover an active Replica and reply with its `ZenohId`, `All` to request the data from the discovered Replica. To avoid contention, this transfer is performed by batch, one `Interval` at a time. * plugins/zenoh-plugin-storage-manager/src/replication/aligner.rs: - Added new variants `AlignmentQuery::All` and `AlignmentQuery::Discovery`. - Added new variant `AlignmentReply::Discovery`. - Updated the `aligner` method to: - Send the `ZenohId` as a reply to an `AlignmentQuery::Discovery`. - Send all the data of the Storage as a reply to an `AlignmentQuery::All`. This leverages the already existing `reply_events` method. - Updated the `reply_events` method to not attempt to fetch the content of the Storage if the action is set to `delete`. Before this commit, the only time this method was called was during an alignment which filters out the deleted events (hence not requiring this code). - Updated the `spawn_query_replica_aligner` method: - It now returns the handle of the newly created task as we want to wait for it to finish when performing the initial alignment. - Changed the consolidation to `ConsolidationMode::Monotonic` when sending an `AlignmentQuery::Discovery`: we only want one reply. - Updated the `process_alignment_reply`: - Process an `AlignmentReply::Discovery` by sending a follow-up `AlignmentQuery::All` to retrieve the content of the Storage of the discovered Replica. - It does not attempt to delete an entry in the Storage when processing an `AlignmentReply::Retrieval`. This could only happen when performing an initial alignment in which case the receiving Storage is empty. We basically only need to record the fact that a delete was performed in the Replication Log. * plugins/zenoh-plugin-storage-manager/src/replication/core.rs: implemented the `initial_alignment` method that attempts to discover a Replica by sending out an `AlignmentQuery::Discovery` on the Aligner Queryable for all Replicas. Before making this query we wait a small delay to give enough time for Zenoh to propagate the routing tables. * plugins/zenoh-plugin-storage-manager/src/replication/service.rs: - Removed the constants `MAX_RETRY` and `WAIT_PERIOD_SECS` as they were no longer needed. - Updated the documentation of the `spawn_start` function. - Removed the previous implementation of the initial alignment that made a query on the key expression of the Storage. - Added a check after creating the `Replication` structure: if the Replication Log is empty, which indicates an empty Storage, then perform an initial alignment. Signed-off-by: Julien Loudet <[email protected]>
- Loading branch information
Showing
3 changed files
with
197 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.