Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@danlaine
Copy link
Collaborator

@danlaine danlaine commented Jul 25, 2025

This PR resolves #1214.

@danlaine danlaine self-assigned this Jul 25, 2025
@danlaine danlaine removed the request for review from patrick-ogrady July 29, 2025 19:08
(sink, stream)
}
Err(e) => {
error!(error = %e, "failed to establish connection, exiting");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We used to re-try on connection errors but I think it migt actually be better to just fail. We don't want the client to keep trying to reconnect indefinitely, and the client doesn't have any retry or timeout logic to help it handle an interrupted connection to a server. I think for the sake of this example it's alright to just give up if the connection fails.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems fine here as this is example code. But can the client user configure a per-request timeout or similar if someone wanted to create a more robust app?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements concurrent operation fetching for the ADB sync protocol to resolve issue #1214. The changes transform the previously sequential sync client into a concurrent one that can handle multiple outstanding requests simultaneously.

  • Replaced sequential operation fetching with a concurrent model using FuturesUnordered
  • Refactored the Resolver trait to support concurrency with Send + Sync + 'static bounds
  • Introduced AnyResolver struct to wrap database access in Arc<RwLock<>> for thread safety

Reviewed Changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
storage/src/adb/any/sync/resolver.rs Adds concurrency bounds to Resolver trait and introduces AnyResolver wrapper
storage/src/adb/any/sync/mod.rs Removes TODO comment and adds new error types for concurrent operations
storage/src/adb/any/sync/metrics.rs New metrics module for tracking sync performance
storage/src/adb/any/sync/client.rs Major refactor to support concurrent operation fetching with gap-finding algorithm
storage/fuzz/fuzz_targets/adb_sync.rs Updates to use new AnyResolver wrapper
examples/sync/src/resolver.rs Refactors resolver to use concurrent I/O with request correlation
examples/sync/src/protocol.rs Adds RequestId for correlating concurrent requests and responses
examples/sync/src/lib.rs Adds error module export
examples/sync/src/error.rs New error handling module for the sync example
Comments suppressed due to low confidence (1)

examples/sync/src/resolver.rs:139

  • [nitpick] The field name _phantom is not descriptive. Consider renaming to _runtime or _context_phantom to better indicate what phantom data this represents.
    _phantom: PhantomData<E>,

Copy link
Contributor

@patrick-ogrady patrick-ogrady left a comment

Choose a reason for hiding this comment

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

I think the async pattern you are now using in the client seems reasonable (I never mind a good swing at making an explicit state machine if the number of states is well-contained).

I'm not sure it'll work for other crates where there are many more states we could be in (like consensus) but if we can simplify it to this here, we should.

}

/// Send a request and receive a response using the persistent connection.
async fn send_request(&self, request: Message) -> Result<Message, ResolverError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

By concurrent here, I mean "interleaved" requests (outstanding requests for multiple ranges).

Copy link
Contributor

@patrick-ogrady patrick-ogrady left a comment

Choose a reason for hiding this comment

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

🎸

@patrick-ogrady patrick-ogrady merged commit 868a146 into main Jul 30, 2025
34 checks passed
@patrick-ogrady patrick-ogrady deleted the danlaine/sync-function branch July 30, 2025 01:17
@codecov
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

❌ Patch coverage is 95.20548% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.37%. Comparing base (81a7bf0) to head (5f32108).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
storage/src/adb/any/sync/client.rs 95.08% 27 Missing ⚠️
storage/src/adb/any/sync/resolver.rs 88.88% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1323      +/-   ##
==========================================
+ Coverage   91.30%   91.37%   +0.06%     
==========================================
  Files         250      251       +1     
  Lines       63382    63583     +201     
==========================================
+ Hits        57872    58096     +224     
+ Misses       5510     5487      -23     
Files with missing lines Coverage Δ
storage/src/adb/any/sync/metrics.rs 100.00% <100.00%> (ø)
storage/src/adb/any/sync/mod.rs 41.17% <100.00%> (-3.27%) ⬇️
storage/src/adb/any/sync/resolver.rs 50.00% <88.88%> (-33.68%) ⬇️
storage/src/adb/any/sync/client.rs 97.32% <95.08%> (+4.07%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81a7bf0...5f32108. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[storage] [sync] During sync, parallelize fetching of batches of operations

3 participants