Skip to content

chore: Fixed randomly failing Postgres tests #8060

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

Merged
merged 7 commits into from
Nov 3, 2024

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Nov 2, 2024

Description

This PR fixes randomly failing postgres tests by

  1. Encapsulating placeholder.delete_plugin() in an atomic transaction
  2. Recalculating plugin positions only if necessary after deleting a plugin (and its descendants)
  3. Ensuring during tests, that the plugin object is in sync with the database

Also, as a positive side effect, this PR

  • Reduces the number of DB queries placeholder.delete_plugin() by one
  • Improves the raw SQL code for recalculating the plugin positions for SQLite databases which since 2018 accept the same subqueries with ROW_NUMBER as Postgres.

This PR will make PR management significantly easier, since failing Postgres tests do not have restarted multiple times for each PR any more.

I am not fully sure what the underlying root cause for the randomness of the failures is, but I speculate that it is a combination of postgres' optimizer and the recalculation of plugin positions occasionally being called despite it would be a no-op.

Related resources

  • #...
  • #...

Checklist

  • I have opened this pull request against develop-4
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined the channel #pr-reviews on our Discord Server to find a “pr review buddy” who is going to review my pull request.

@fsbraun fsbraun force-pushed the fix/replace-raw-sql branch 3 times, most recently from f22473c to e125254 Compare November 2, 2024 20:55
@fsbraun fsbraun force-pushed the fix/replace-raw-sql branch from e125254 to 6ab8437 Compare November 2, 2024 22:14
@fsbraun fsbraun changed the title fix: Improve plugin position update queries chore: Fixed randomly failing Postgres tests Nov 2, 2024
@fsbraun fsbraun requested a review from marksweb November 2, 2024 22:44
@fsbraun fsbraun marked this pull request as ready for review November 2, 2024 22:44
Copy link
Member

@marksweb marksweb left a comment

Choose a reason for hiding this comment

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

Great work - LGTM 🎉

@fsbraun fsbraun added the needs to be backported Commits need to be backported label Nov 3, 2024
@fsbraun fsbraun merged commit 894458e into django-cms:develop-4 Nov 3, 2024
51 checks passed
@fsbraun fsbraun deleted the fix/replace-raw-sql branch November 3, 2024 15:50
fsbraun added a commit that referenced this pull request Nov 3, 2024
* feat: Use subquery for plugin renumbering also for sqlite

* Isolate error and list database

* Refresh plugins

* Reintroduce shift

* Remove debug code

* Update

---------

Co-authored-by: Github Release Action <info@django-cms.org>
@fsbraun fsbraun added 4.1 5.0 and removed needs to be backported Commits need to be backported labels Nov 6, 2024
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.

2 participants