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

Make tobira serve work with PostgreSQL "hot standby" #725

Open
LukasKalbertodt opened this issue Mar 1, 2023 · 0 comments
Open

Make tobira serve work with PostgreSQL "hot standby" #725

LukasKalbertodt opened this issue Mar 1, 2023 · 0 comments
Labels
area:backend Everything backend related area:database The Tobira database kind:improvement

Comments

@LukasKalbertodt
Copy link
Member

PostgreSQL offers a feature called "hot standby". This mode is read-only and has a few other limitations. I'm not yet 100% sure when a server would be in that mode, but in either case: tobira serve should likely support that as well as it can.

Obviously, GraphQL mutations won't work. In that case, returning 500 is fine, though "503 Service Unavailable" would be better.

Read-only GraphQL queries should just work. I think they currently do not work as all of our queries are using a serializable transaction. Hot standby mode does NOT support serializable transactions (see docs above). For read-only queries, we likely can get the same data consistency guarantees with a lower transaction mode, especially considering that the hot standby is read-only anyway so... we could not use a transaction at all I guess? We can either detect whether the DB is in hot standby mode and switch to a lower isolation level OR we could inspect the GraphQL query and, for read-only ones, switch to a lower isolation level. Or both.

Further, starting Tobira will try to apply DB migrations, also happening in a serializable transaction. We have to find a solution to that as wlel.

By the way, tobira worker likely can't work at all in this mode as all of its functions need to write to the DB.

@LukasKalbertodt LukasKalbertodt added area:backend Everything backend related kind:improvement area:database The Tobira database labels Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:backend Everything backend related area:database The Tobira database kind:improvement
Projects
None yet
Development

No branches or pull requests

1 participant