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

AAP-16926 Delete unpartitioned tables in a separate transaction #14572

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

AlanCoding
Copy link
Member

@AlanCoding AlanCoding commented Oct 13, 2023

SUMMARY

My prior merge #14055 broke cleanup jobs, and this is me trying to fix that.

The issue is pretty high level:

https://stackoverflow.com/questions/12838111/django-db-migrations-cannot-alter-table-because-it-has-pending-trigger-events

Every migration is inside a transaction. In PostgreSQL you must not update the table and then alter the table schema in one transaction.

And what we saw were errors of this type:

django.db.utils.InternalError: could not find trigger 17121

That error is really hard to make sense of. Within my process of troubleshooting this issue, I tried to manually drop all the constraints on the unpartitioned tables before dropping them. That led to this interesting error:

psycopg.errors.ObjectInUse: cannot ALTER TABLE "main_host" because it has pending trigger events

That starts to jive really well with the above statement that "you must not update the table and then alter the table schema".

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API

@AlanCoding AlanCoding marked this pull request as ready for review October 13, 2023 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants