Skip to content

Convert more endpoints to the read-only follower database #3118

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

Conversation

jtgeibel
Copy link
Member

@Turbo87
Copy link
Member

Turbo87 commented Dec 24, 2020

do we have some docs somewhere that explain when to use which DB?

@jtgeibel
Copy link
Member Author

I've pushed another commit to this PR, converting even more GET endpoints over. A word of caution, we need to test this well in staging (the new commit is live there now). I can split the 2nd commit off into its own PR if we decide that is safer.

The reason is, we can't catch these bugs in CI. When running tests, everything happens inside a single transaction that is eventually discarded, so all endpoints accessed in a single test have to go through the same connection. It's possible we could switch the 1 connection between read-only and read-write during an individual test, but we don't have the test infrastructure in place for that.

The staging environment is set up such that it defines a READ_ONLY_REPLICA_URL pointing to the primary database. In this configuration, if an endpoint is incorrectly converted to the follower database then we will report (and log) errors about the read-only connection.

do we have some docs somewhere that explain when to use which DB?

The general rule of thumb I have is that anything GET should be idempotent and could be eligible for the follower database. Of course there are some exceptions, notably the download endpoint which increments the download count.

I think we should also avoid converting endpoints related to authentication. While there should only ever be a slight delay on the follower database, we don't want a user who just logged in to have issues accessing /me endpoints for example.

@jtgeibel
Copy link
Member Author

I've tested all these endpoints on staging, and didn't see any issues. It actually took me a little while to figure out the API of the 2 deprecated routes. I believe we can remove these routes, as I see no activity on them in the logs from the last month, but for now they are converted to the follower, for whatever that is worth.

Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

the only thing I'm a little bit worried about is the potential loss of consistency from using the slightly delayed read replica of the database. this could potentially mean that if the frontend modified something and then queried for the same resource it could still see the old data. I don't know how long that delay is in practice though.

(feel free to r=me)

@jtgeibel
Copy link
Member Author

@bors r=Turbo87

(Merging now, going to deploy this separately from the current deploy.)

@bors
Copy link
Contributor

bors commented Dec 31, 2020

📌 Commit aea4457 has been approved by Turbo87

@bors
Copy link
Contributor

bors commented Dec 31, 2020

⌛ Testing commit aea4457 with merge 1c65ab3...

@bors
Copy link
Contributor

bors commented Dec 31, 2020

☀️ Test successful - checks-actions
Approved by: Turbo87
Pushing 1c65ab3 to master...

@bors bors merged commit 1c65ab3 into rust-lang:master Dec 31, 2020
@jtgeibel jtgeibel deleted the more-endpoints-on-readonly-follower-db branch March 7, 2021 17:49
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.

5 participants