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

Handles closed db connections #1747

Merged
merged 5 commits into from
Dec 2, 2021
Merged

Handles closed db connections #1747

merged 5 commits into from
Dec 2, 2021

Conversation

dkliban
Copy link
Member

@dkliban dkliban commented Dec 2, 2021

When the authentication middleware was added in pulpcore 3.15, it became the first place
in the content app that made an attempt to use the database. As a result, it is a convinient
place to handle InterfaceError and OperationalError which are raised when the database
connection has been closed. When this occurs, Handler._reset_db_connection() is called to
clean up the database connection and the middleware tries to use the database again.

If the database connection is closed later in the handling of the request by the content app,
the user will still get a 500 error. However, the next request will be handled properly.

This patch also adds a call to Handler._reset_db_connection() inside the heartbeat method.

fixes: #9276
https://pulp.plan.io/issues/9276

Please be sure you have read our documentation on creating PRs:
https://docs.pulpproject.org/contributing/pull-request-walkthrough.html

@pulpbot
Copy link
Member

pulpbot commented Dec 2, 2021

Attached issue: https://pulp.plan.io/issues/9598

@@ -0,0 +1 @@
Fixed bug where the content app would stop working after a brief loss of connection to the database.
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be a backport? Or is the fix on main completely different?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a backport. I did not use the cherry-pick script. In addition to this backport, I had to backport a few other commits.

Copy link
Member

Choose a reason for hiding this comment

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

This updated version is what I expected. Thanks!

@mdellweg
Copy link
Member

mdellweg commented Dec 2, 2021

This PR is made against a stable branch. So i expect the commits to be generated by the cherry-pick-script, which will clearly identify what has been cherry-picked, what was the original issue and what backport issue is fixed.

@bmbouter
Copy link
Member

bmbouter commented Dec 2, 2021

I think we do want the clarity the backport script provides, but you can also do these commands manually to ammend your commit to look like what it would produce.

dralley and others added 5 commits December 2, 2021 09:23
When the authentication middleware was added in pulpcore 3.15, it became the first place
in the content app that made an attempt to use the database. As a result, it is a convinient
place to handle InterfaceError and  OperationalError which are raised when the database
connection has been closed. When this occurs, Handler._reset_db_connection() is called to
clean up the database connection and the middleware tries to use the database again.

If the database connection is closed later in the handling of the request by the content app,
the user will still get a 500 error. However, the next request will be handled properly.

This patch also adds a call to Handler._reset_db_connection() inside the heartbeat method.

backports #9276

fixes: #9598
https://pulp.plan.io/issues/9598

(cherry picked from commit 3faa649)
SimpleTestCase does not allow database access.

[noissue]

(cherry picked from commit 342587a)
Copy link
Member

@bmbouter bmbouter left a comment

Choose a reason for hiding this comment

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

This looks great. Having done some backports recently, each of these changes looks right to me. Thanks! 🥇

@dkliban dkliban merged commit 68412d5 into pulp:3.16 Dec 2, 2021
@dkliban dkliban deleted the 9598 branch December 2, 2021 14:57
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

5 participants