-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: change async-bb8 fork and tokio spawn for concurrent database calls #2774
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
Conversation
This file contains hidden or 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
Co-authored-by: akshay.s <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
dracarys18
previously approved these changes
Nov 9, 2023
dracarys18
previously approved these changes
Nov 14, 2023
akshay-97
previously approved these changes
Nov 14, 2023
SanchithHegde
previously approved these changes
Nov 14, 2023
ae9581d
SanchithHegde
approved these changes
Nov 15, 2023
dracarys18
approved these changes
Nov 16, 2023
akshay-97
approved these changes
Nov 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
Currently, In GetTracker, UpdateTracker, and PostUpdateTracker, the concurrent database calls become sequential because of the mutex lock of async-bb8 to get a connection from the connection pool.
Any errors inside the spawned concurrent calls propagated as an internal server error.
Solution:
Instead, use the has_broken function from the connection manager to check whether a connection is valid and run the function immediately. So that inside all concurrent calls, acquire a lock to pick a connection and then release before doing an I/O call.
Match on the JoinHandle and propagate the join error as an internal server error and others as it is.
The runtime changed into tokio::main, so that we get more performance with tokio::spawn instead using actix-web::main
Added Box::pin to large futures
Motivation and Context
To reduce the overall latency of the confirm call.
How did you test it?
A load test setup is required with tracing enabled. A minimalistic postman load test tool itself suffices.
Enable traces_enabled=true, use_xray_generator = true. Run the load test, narrow it down to get_traces in traces, and check the waterfall.
Checklist
cargo +nightly fmt --all
cargo clippy