-
Notifications
You must be signed in to change notification settings - Fork 142
Use the ShardedThreadedConnectionPool to disconnect after policy load #2584
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
Conversation
da207fa to
29c5d25
Compare
micahlee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a couple of further follow ups. Also, I'm not entirely sure if it was accidental or intentional, but we should spell out 'policy' in the commit message (plcy -> policy).
If you're trying to use a shorter message, I would suggest changing the headline and adding a body like:
Disconnect the database connection after policy loads
... Add more detail about why (Postgres's catcache) and how (with the shardedconnection pool) in the commit message body...
9aeb86e to
55f247f
Compare
micahlee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for adding the extra comments, @ajay-vel !
PostgreSQL has many types of caches, one of which is the "catalog cache".When a connection is established to the database, this cache is initialized alongside it, and persists for the duration of the connection. This cache contains references to Database Objects, such as indexes, etc. (not data records themselves).This cache is not cleaned up by the system automatically. However, if the connection is disconnected, the cache is dumped. Further reading: Postgres community email thread: https://www.postgresql.org/message-id/flat/20161219.201505.11562604.horiguchi.kyotaro@lab.ntt.co.jp. The default connection pool does not support closing connections.We must be able to close connections on demand, to clear the connection cache after policy loads. The ShardedThreadedConnectionPool does support closing connections on-demand [docs](https://www.rubydoc.info/github/jeremyevans/sequel/Sequel/ShardedThreadedConnectionPool)
55f247f to
af95002
Compare
|
Code Climate has analyzed commit af95002 and detected 1 issue on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 89.8%. View more on Code Climate. |
Desired Outcome
The desired outcome of this PR is to resolve the memory leak in the postgres container causing it to OOM.
Implemented Changes
This PR:
Makes use of ShardedThreadedConnectionPool in Sequel so that active connections can be closed.
Closing active connections from conjur ensures that memory consumption in postgres stays low and a new connection for conjur is established every-time on policy load instead of using the existing connection.
- Connected Issue/Story
Changelog
CHANGELOG update
Test coverage
changes, or
Documentation
Behavior
Security