Skip to content

Conversation

glehmann
Copy link
Member

@glehmann glehmann commented Aug 18, 2025

Koji keeps opening new connections to the database, and keeps them open
up to the point where no new connection can be open. Koji then starts
to fail, with a database outage error message.

This scripts terminates the connexions older that 10 minutes, and is
intended to run every minute on the koji server.

@gduperrey gduperrey requested a review from stormi August 18, 2025 08:51
Copy link
Contributor

@ydirson ydirson left a comment

Choose a reason for hiding this comment

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

There should be some context, what pg connections are we talking about?

@glehmann glehmann force-pushed the gln/pg-idle-connections-qsqy branch from 9ed45a7 to 729f75d Compare August 19, 2025 15:23
@glehmann glehmann requested a review from ydirson August 19, 2025 15:23
Copy link
Contributor

@ydirson ydirson left a comment

Choose a reason for hiding this comment

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

lgtm (not 100% sure though, whether that the print() before commit() should not be saying "terminating", but that should not have much impact 😉)

Koji keeps opening new connections to the database, and keeps them open
up to the point where no new connection can be open. Koji then starts
to fail, with a database outage error message.

This scripts terminates the connexions older that 10 minutes, and is
intended to run every minute on the koji server.

Signed-off-by: Gaëtan Lehmann <[email protected]>
@glehmann glehmann force-pushed the gln/pg-idle-connections-qsqy branch from 729f75d to cb277e4 Compare August 20, 2025 09:34
@glehmann
Copy link
Member Author

Yes, that was a weird place to add it.
I've also used the connection as a context manager.

Copy link
Member

Choose a reason for hiding this comment

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

It looks like a temporary workaround, so I'm not entirely at ease with merging this and risking to make it a long lived hack.

Unless that's what the koji developers recommend?

Copy link
Member

Choose a reason for hiding this comment

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

It is not what koji developers recommend at all. Quoting Mike McLean from :

Koji works on a one connection per thead model. If httpd leaves threads active, then they will keep their db connection.
See discussion in https://pagure.io/koji/issue/4175

Issue #4175: Add an limit for the database connections - koji - Pagure.io

Most likely the solution to your issue lies in httpd configuration
That said, it is normal for kojihub to keep a lot of connections open.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is indeed a temporary workaround.

@stormi stormi requested a review from nathanael-h August 28, 2025 11:06
@stormi
Copy link
Member

stormi commented Aug 28, 2025

I'm converting this to draft. We probably don't want to spend more time on it unless we can't find a proper fix (and @nathanael-h might already have found one).

@stormi stormi marked this pull request as draft August 28, 2025 11:07
@glehmann
Copy link
Member Author

glehmann commented Sep 4, 2025

We don't need it anymore 🎉

@glehmann glehmann closed this Sep 4, 2025
@glehmann glehmann deleted the gln/pg-idle-connections-qsqy branch September 4, 2025 08:59
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.

5 participants