-
-
Notifications
You must be signed in to change notification settings - Fork 883
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
Use transactions for some DB actions. #1161
Comments
@dessalines Did you fix this in the DB rewrite? |
No not yet. |
I think a big part of the work here is to make all of the db_schema traits take a connection instead of a pool, otherwise they won't be usable inside a transaction; I've only done a cursory look though as I was trying to use a transaction and found it to not really be possible at the moment. Are there any major blockers for this issue? |
I want to caution against "blindly" using transactions everywhere. In my opinion transactions should only be used where absolutely necessary. The priority with a DB for perf is to have as little and short-time locks as possible. Only then can stuff run nicely in parallel. For context, I'm someone running a (unrelated) postgresql instance that's > 4TB in size, uses 1TB of RAM, has 200k weekly active users and handles on average 1000 to 5000 INSERTs per second.
Here's some other suggestions:
|
I'll try implementing a cache based on moka for dereference() in activitypub-federation-rust over the weekend. |
Great to have input from someone running a database that gets hammered like that!
Totally agree, but I would still think most methods that involve inserting records into multiple related tables should be done in transactions in order for them to succeed or fail together yes?
Absolutely, holding a connection while doing an HTTP request is definitely not something you want to do! |
Yes, that is true. My argument is mainly against just putting transactions around everything as a "precaution" which I've seen happen before, especially because of misconceptions of what transactions help with. Sometimes they help, sometimes they make things worse - sadly knowing exactly when needs pretty deep knowledge of the database. Also, in many cases it's possible to get the same effect or something acceptable without using a transaction. |
Thanks for this work. I could definitely use some help optimizing the DB. The community_language stuff def needs to be reworked. |
We are using transactions in various places now. |
Some DB actions like transfer community, should probably be transactions, so that if one DB action fails, it doesn't end up in a half-complete state.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: