Skip to content
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

Minor Refactoring of re-used code and server stat reporting #129

Merged
merged 3 commits into from
Aug 18, 2022

Conversation

zainkabani
Copy link
Contributor

Moves the loop of sending and receiving in the 'Q' and 'S' packets into a function to reduce same code.

Sets server to active on checkout and moves setting server idle to end of loop before it is dropped

Copy link
Collaborator

@levkk levkk left a comment

Choose a reason for hiding this comment

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

Awesome! FYI @drdrsh , minor change in how we mark servers as idle/active in stats, I think this is the correct way (i.e. pgbouncer does this I believe).

if !server.in_transaction() {
self.stats.transaction(self.process_id, address.id);

// Release server back to the pool if we are in transaction mode.
// If we are in session mode, we keep the server until the client disconnects.
if self.transaction_mode {
self.stats.server_idle(server.process_id(), address.id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Idle in transaction would be a cool state to add to our stats some day.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I originally had some confusion about this metric. I thought it was reporting the state of server connections internally. But it seems like the way pgbouncer is doing it, is it's actually determining which connections are checked out, or no checked out

@levkk levkk merged commit 5948fef into postgresml:main Aug 18, 2022
@zainkabani zainkabani deleted the zain/minor-refacoring branch August 18, 2022 16:17
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.

None yet

2 participants