Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

improve is_closed effectiveness#1229

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

conradludgate
Copy link
Contributor

Hi. We noticed thatis_closed() is not always super effective, especially in thepostgres crate. I've added a couple utilities to try and improve this state.

Problem 1:is_closed() checks if the channel is closed, not if the connection is closed. These can be the same, but currently the channel is only closed whenConnection is dropped. Inpostgres::Client,Connection never gets dropped. Fix is to force close the receiver on terminal state.

Problem 2: The connection will only turn if something happens. Sometimes closure can be silent, so even still it seems open. You only can check it's valid if you try to run a query or if the TCP keepalive triggers. Running aSELECT 1; is a common workaround, but in my understanding, a singleSYNC message is cheaper and doesn't cause any logging - so it's a better liveness check than running a full query.

Thanks for your consideration

ololobus reacted with heart emoji
self.connection.block_on(self.client.batch_execute(query))
}

/// Check the connection is alive and wait for the confirmation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Check the connection is alive and wait for the confirmation.
/// Checkthatthe connection is alive and wait for the confirmation.

simple_query::batch_execute(self.inner(), query).await
}

/// Check the connection is alive and wait for the confirmation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Check the connection is alive and wait for the confirmation.
/// Checkthatthe connection is alive and wait for the confirmation.

Copy link
Member

@paolobarbolinipaolobarbolini left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@paolobarbolinipaolobarbolini merged commit65920b8 intorust-postgres:masterOct 5, 2025
@conradludgateconradludgate deleted the fix-connection-closure branchOctober 5, 2025 17:10
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@paolobarbolinipaolobarbolinipaolobarbolini approved these changes

+1 more reviewer

@tristan957tristan957tristan957 left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@conradludgate@paolobarbolini@tristan957

[8]ページ先頭

©2009-2025 Movatter.jp