Skip to content

service: remove the Reconnect trait#13525

Merged
benesch merged 1 commit into
MaterializeInc:mainfrom
benesch:client-no-reconnect
Jul 8, 2022
Merged

service: remove the Reconnect trait#13525
benesch merged 1 commit into
MaterializeInc:mainfrom
benesch:client-no-reconnect

Conversation

@benesch

@benesch benesch commented Jul 8, 2022

Copy link
Copy Markdown
Contributor

This commit removes the Reconnect trait, which augmented the
GenericClient trait with a reconnect method. Folks that previously
called Client::reconnect instead construct a new client from scratch.

This eliminates several heaps of complexity. Clients no longer need to
support a "disconnected" state, as they are connected at construction.
The ActiveReplication controller doesn't have a complicated protocol
with asynchronous tasks where commands are drained after an error;
instead, the controller simply constructs a fresh after an error.

Touches MaterializeInc/database-issues#3125.
Touches MaterializeInc/database-issues#3718.

Motivation

  • This PR refactors existing code.

Testing

  • This PR has adequate test coverage / QA involvement has been duly considered.

Release notes

This PR includes the following user-facing behavior changes:

  • n/a

This commit removes the `Reconnect` trait, which augmented the
`GenericClient` trait with a `reconnect` method. Folks that previously
called `Client::reconnect` instead construct a new client from scratch.

This eliminates several heaps of complexity. Clients no longer need to
support a "disconnected" state, as they are connected at construction.
The `ActiveReplication` controller doesn't have a complicated protocol
with asynchronous tasks where commands are drained after an error;
instead, the controller simply constructs a fresh after an error.

Touches #12946.

@frankmcsherry frankmcsherry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This all looks good to me. I like the fact that there is one code path now for establishing and re-establishing connections, and I think that is a great way forward to higher confidence code!

@benesch benesch merged commit 2e02fea into MaterializeInc:main Jul 8, 2022
@benesch benesch deleted the client-no-reconnect branch July 8, 2022 22:37
Comment on lines +91 to +100
match ComputeGrpcClient::connect_partitioned(addrs).await {
Ok(client) => Ok(client),
Err(e) => {
warn!(
"error connecting to replica {replica_id}, retrying in {:?}: {e}",
state.next_backoff.unwrap()
);
Err(e)
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this prevents replicas from being dropped if they never succeed in connecting to any peer. Even if dropped, they don't see it because they don't try to receive on their command channel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

4 participants