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

fix(db): Fix read replica strategy #3426

Merged
merged 1 commit into from
Feb 15, 2024
Merged

Conversation

matthewelwell
Copy link
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Fixes the logic to look for the actual enum instead of the value of the enum.

How did you test this code?

Updated the tests but also ran the API locally with REPLICA_DATABASE_URLS configured to point at a replicated database and confirmed that it worked as expected.

Copy link

vercel bot commented Feb 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Feb 15, 2024 6:16pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 15, 2024 6:16pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 15, 2024 6:16pm

@khvn26
Copy link
Member

khvn26 commented Feb 15, 2024

Do we need to add a default setting value for the folks that have read replicas enabled?

Copy link
Contributor

github-actions bot commented Feb 15, 2024

Uffizzi Preview deployment-46651 was deleted.

@matthewelwell
Copy link
Contributor Author

Do we need to add a default setting value for the folks that have read replicas enabled?

The default is ReadReplicaStrategy.DISTRIBUTED, which maintains the previous behaviour.

Copy link
Contributor

@zachaysan zachaysan left a comment

Choose a reason for hiding this comment

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

I'm a little confused as to why the .value was added in the first place. I vaguely remember thinking it was necessary based on something.

@khvn26
Copy link
Member

khvn26 commented Feb 15, 2024

Do we need to add a default setting value for the folks that have read replicas enabled?

The default is ReadReplicaStrategy.DISTRIBUTED, which maintains the previous behaviour.

̶I̶t̶ ̶s̶h̶o̶u̶l̶d̶ ̶b̶e̶ ̶̶R̶e̶a̶d̶R̶e̶p̶l̶i̶c̶a̶S̶t̶r̶a̶t̶e̶g̶y̶.̶D̶I̶S̶T̶R̶I̶B̶U̶T̶E̶D̶.̶v̶a̶l̶u̶e̶̶ ̶s̶h̶o̶u̶l̶d̶n̶'̶t̶ ̶i̶t̶?̶ UPD It should not due to env.enum behaviour.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (16a2468) 95.92% compared to head (025575c) 95.92%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3426   +/-   ##
=======================================
  Coverage   95.92%   95.92%           
=======================================
  Files        1090     1090           
  Lines       33949    33949           
=======================================
  Hits        32564    32564           
  Misses       1385     1385           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@matthewelwell
Copy link
Contributor Author

I'm a little confused as to why the .value was added in the first place. I vaguely remember thinking it was necessary based on something and I'm surprised that the test suite didn't caught it.

The test suite was essentially monkey patching the settings module to whatever it wanted, so the logic was sound when the setting was monkeypatched to be .value. The issue is that the tests weren't exercising the env.enum parsing logic which actually returns an instance of the enum class.

@matthewelwell matthewelwell added this pull request to the merge queue Feb 15, 2024
Merged via the queue into main with commit d63a289 Feb 15, 2024
23 checks passed
@matthewelwell matthewelwell deleted the fix(db)/fix-replica-strategy branch February 15, 2024 18:22
matthewelwell added a commit that referenced this pull request Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants