Skip to content

optionally use alternate db connection for orm stuff (users/roles) #1180

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 1 commit into from
May 24, 2023

Conversation

melange396
Copy link
Collaborator

on the live system, the prod api servers are used when creating new users -- either via the admin page, or when users register at our google form (which just posts to another admin url). users are added by the api servers as records in the api_user table and their roles are stored in the associated user_role_link table (and the role names themselves are stored in the user_role table, but it isnt updated very frequently). HOWEVER, the prod api servers use the prod db replicas, and the prod db replicas are set up to mirror any changes made to the prod master db. so if the api servers are creating/updating users on replicas, the user tables on the replicas will soon be out of sync with each other and the master 😞

this change lets us (optionally) use an alternate db connection for the users/roles stuff. that way, we can have the prod api servers using the [distributed, loadbalanced, whatevs] db replicas for large epidata queries, but they can all use the master for user operations, eliminating the sync issues.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

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

seems legit.

noting here that this will direct all user activity to primary, both reads and writes, but maybe that's an okay stopgap?

Copy link
Contributor

@korlaxxalrok korlaxxalrok left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@melange396
Copy link
Collaborator Author

yes, it will indeed direct all reads and writes to the master db. this is not intended to be permanent, but it allows us to continue with the api keys deployment.

@melange396 melange396 merged commit c74841f into dev May 24, 2023
@melange396 melange396 deleted the api-keys-also branch May 24, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants