Skip to content

RUST-663 Support $merge and $out executing on secondaries #1360

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Apr 17, 2025

RUST-663

Attempt 1: add a new method on Operation that could update the stored selection criteria before server selection given a topology snapshot. Didn't work because server selection might need to wait for handshake to finish and if so the snapshot won't have the version information.

Attempt 2: Update Client::select_server to take an Operation rather than a string operation name, but it's called from various contexts that don't have an operation to give which would need to synthesize one, and that seemed worse.

Attempt 3 (this PR): Plumb a single callback from the Operation into select_server (no-op by default) to override selection criteria in the inner loop of server selection, based on the always-most-recent view of topology.

As a side effect, I factored Command construction out into its own function so that it was easier to record the final effective selection criteria rather than the static Operation-associated criteria; I think this makes the inner portion of command execution a bit easier to read and makes it easier to keep track of what's going on between the various flavors of execute_whatever_with_whatever in there.

@@ -651,78 +661,9 @@ impl Client {
let start_time = Instant::now();
let command_result = match connection.send_message(message).await {
Ok(response) => {
async fn handle_response<T: Operation>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pulled this out and renamed it for readability, but the body is unchanged.

Copy link
Contributor

Choose a reason for hiding this comment

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

ha, I also did this in #1358 (minus the rename)

@@ -205,7 +205,7 @@ impl TopologyDescription {
&self,
address: &ServerAddress,
command: &mut Command,
criteria: Option<&SelectionCriteria>,
criteria: &SelectionCriteria,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another side effect: this method no longer receives an Option, so it could be slightly simplified.

@abr-egn abr-egn marked this pull request as ready for review April 17, 2025 19:05
@abr-egn abr-egn requested a review from a team as a code owner April 17, 2025 19:05
@abr-egn abr-egn requested review from isabelatkinson and removed request for a team April 17, 2025 19:05
Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

lgtm!

@@ -651,78 +661,9 @@ impl Client {
let start_time = Instant::now();
let command_result = match connection.send_message(message).await {
Ok(response) => {
async fn handle_response<T: Operation>(
Copy link
Contributor

Choose a reason for hiding this comment

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

ha, I also did this in #1358 (minus the rename)

@abr-egn abr-egn force-pushed the RUST-663/aggregation-read-pref branch from 6c0c335 to 50c75de Compare April 28, 2025 15:47
@abr-egn abr-egn requested a review from isabelatkinson April 28, 2025 17:59
@abr-egn
Copy link
Contributor Author

abr-egn commented Apr 28, 2025

Rebase required a little bit of rewriting, so please do another look over.

Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

LGTM. we might not be able to merge this til the cargo-deny error is fixed because of the rules I added for RUST-1907

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.

2 participants