Database race conditions #3087
Unanswered
matheusbaptistella
asked this question in
Q&A
Replies: 1 comment
-
No. Let the database manage writes, and use a single pool. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone, I'm working on a project to build an api in Rust using Axum and Sqlx. I have implemented some functions to read from the database and functions to write to it. I am running 2 instances of this api simultaneously using Docker compose and they interact with the same db. I was wondering if there could be potential issues with race conditions (and how to address them) or if Sqlx's connection pool prevents it from happening. I currently supply the connection pool as an axum::State for my handler functions.
I thought about using RwLock as a wrapper for my connection pool:
would this be the best approach?
Beta Was this translation helpful? Give feedback.
All reactions