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

Handle Integrity Error in Django 3.2 Upgrade #12138

Open
AllanOXDi opened this issue May 7, 2024 · 2 comments
Open

Handle Integrity Error in Django 3.2 Upgrade #12138

AllanOXDi opened this issue May 7, 2024 · 2 comments
Labels
DEV: backend Python, databases, networking, filesystem... P0 - critical Priority: Release blocker or regression

Comments

@AllanOXDi
Copy link
Member

Observed behavior

Encountering integrity errors post-upgrade to Django 3.2 due to invalid data in the local database. Not sure how we got here but worth looking into.

Errors and logs

[python-devserver] django.db.utils.IntegrityError: 
The row in table 'logger_usersessionlog' with primary key '905c3e6ef149e1b4bacddfe782ff906f' 
has an invalid foreign key: logger_usersessionlog.user_id 
contains a value '2f4536317ea71e134e84f0fb39698c02' 
that does not have a corresponding value in kolibriauth_facilityuser.id.

Steps to reproduce

Upgrade to Django 3.2
Reinstall Python dependencies

Context

develop

@AllanOXDi AllanOXDi added the DEV: backend Python, databases, networking, filesystem... label May 7, 2024
@rtibbles
Copy link
Member

rtibbles commented May 7, 2024

I took a look at the database where @AllanOXDi saw this issue, and it did seem contained to this single row. Still at a bit of a loss as to how this happened, but we could probably handle this during upgrade before the Django machinery is initialized by doing a PRAGMA foreign_key_check; statement and dealing with the results, probably just by deleting the offending rows.

@rtibbles rtibbles added the P0 - critical Priority: Release blocker or regression label May 7, 2024
@rtibbles
Copy link
Member

rtibbles commented May 7, 2024

I have flagged this as P0 for now, as although I think it is a highly unlikely scenario, it has happened and if it happened to an end user, it would be unrecoverable without losing all data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... P0 - critical Priority: Release blocker or regression
Projects
None yet
Development

No branches or pull requests

2 participants