Project

Profile

Help

Backport #9598

closed

Backport #9276 to 3.16: Content app can have unusable/closed db connections in pulpcore 3.15/3.16

Added by dkliban@redhat.com about 3 years ago. Updated about 3 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

100%

Estimated time:
Triaged:
Yes
Sprint Candidate:
No
Tags:
Katello
Sprint:
Sprint 109
Quarter:

Description

We've seen multiple times the django.db.utils.InterfaceError: connection already closed while using content app. See related issues.

A current workaround is to reset the db connection in multiple places in the code. This "solution" is likely not reliable if we are not resetting db connection before every db request.

This problem needs investigation to understand why Django doesn't take care of the db connections itself, and how to solve it properly.


Related issues

Copied from Pulp - Issue #9276: Content app can have unusable/closed db connections in pulpcore 3.15/3.16CLOSED - CURRENTRELEASEdkliban@redhat.comActions
Actions #1

Updated by dkliban@redhat.com about 3 years ago

  • Copied from Issue #9276: Content app can have unusable/closed db connections in pulpcore 3.15/3.16 added
Actions #2

Updated by dkliban@redhat.com about 3 years ago

  • Sprint/Milestone deleted (3.17.0)
Actions #3

Updated by pulpbot about 3 years ago

  • Status changed from NEW to POST

Added by dkliban@redhat.com about 3 years ago

Revision 1ddf16a0 | View on GitHub

Handles closed db connections

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 3faa649ddb0737c23d1e309a8c38ecb41804cebe)

Actions #4

Updated by dkliban@redhat.com about 3 years ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100
Actions #5

Updated by pulpbot about 3 years ago

  • Sprint/Milestone set to 3.16.1
Actions #6

Updated by pulpbot about 3 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF