Skip to content

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
Contributor

@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
Contributor

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.

2 participants