-
Notifications
You must be signed in to change notification settings - Fork 415
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
fix: odd behaviour seen when using REPLICA_DATABASE_URLS #3771
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@zachaysan @khvn26 I am requesting a review from both of you on this PR. Zach, because you have the context from our investigation of this issue. Kim, because you might have some context as to why |
Uffizzi Preview |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3771 +/- ##
=======================================
Coverage 95.91% 95.91%
=======================================
Files 1102 1102
Lines 34782 34782
=======================================
Hits 33362 33362
Misses 1420 1420 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to see this fixed, but we really should make a ticket for creating a test suite to run with a replica read database in addition to running the whole suite as just the default database. I know 99% of the time it would just duplicate the work, but the small part of the time to catch these regressions would really help out to find issues for our clients that use the replica databases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved but echoing Zach's proposal here. I'm sure we're going to bump into problems with replicated setups in the future, see https://andrewbrookins.com/python/scaling-django-with-postgres-read-replicas/ ("Solving Consistency Problems Caused By Replication Lag").
@zachaysan @khvn26 yeah, you're both right for sure. I hoped it would be as simple as e.g.: DATABASE_URL=postgres://postgres:[email protected]:5432/flagsmith \
REPLICA_DATABASE_URLS=postgres://postgres:[email protected]:5432/flagsmith \
pytest but this causes all the tests to fail with a spurious error:
I agree we should implement some testing against this, but it looks like it needs some thought. |
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingdocs/
if required so people know about the feature!Changes
Fixes #3681.
How did you test this code?
Ran the API locally with
REPLICA_DATABASE_URLS
set up to point to the same database asDATABASE_URL
and observed that, without this change, I received an exception when trying to create a Feature.Once I made this change, I no longer received the exception.