[Backend #8] How to avoid deadlock in DB transaction? Queries order matters!

  Рет қаралды 23,474

TECH SCHOOL

TECH SCHOOL

Күн бұрын

Пікірлер: 45
@sea-entertainment2159
@sea-entertainment2159 2 жыл бұрын
2:00 I really appreciate that you not only explain concepts in theory, but then show us in a very practical way by literally running two concurrent psql terminals. Sometimes concurrency can feel very abstract, and yet you show us very clearly how this problem can arise.
@TECHSCHOOLGURU
@TECHSCHOOLGURU 2 жыл бұрын
Thanks a lot!
@worrapongable
@worrapongable Жыл бұрын
Yes i think so too.
@lacascadaobregon
@lacascadaobregon 2 жыл бұрын
Every sentence is literally great information. I watch these slowly and learn so much. So many golden nuggets of knowledge every video
@TECHSCHOOLGURU
@TECHSCHOOLGURU 2 жыл бұрын
Great to hear!
@dangbey4822
@dangbey4822 2 жыл бұрын
Best course I have ever took
@pshaddel
@pshaddel 15 күн бұрын
Nice video Man! Keep it up!
@thestacksdev
@thestacksdev 2 жыл бұрын
Truly thankful for the content, I can't imagine how long I would have taken figuring out the deadlock issue🥳
@oduber.vasquez
@oduber.vasquez 4 жыл бұрын
Excellent contribution, every day I learn more with your videos, thank you very much!
@TECHSCHOOLGURU
@TECHSCHOOLGURU 4 жыл бұрын
Glad to hear that!
@orkhanrustamli2039
@orkhanrustamli2039 2 жыл бұрын
Dude, I have took a lot of bootcamps, courses on Udemy, KZbin and others, but honestly, none has explained stuff you are doing. Keep it going! Moreover I would like to see a series about create microserviced app containing graphql/rest/grpc together! thanks!
@TECHSCHOOLGURU
@TECHSCHOOLGURU 2 жыл бұрын
Great to hear!
@StyleTrick
@StyleTrick 4 жыл бұрын
Great video explaining this, truly awesome content by the way!
@TECHSCHOOLGURU
@TECHSCHOOLGURU 4 жыл бұрын
Thank you! Much appreciated!
@jounger
@jounger Жыл бұрын
mind blowing, thanks for sharing amazing knowledge
@worrapongable
@worrapongable Жыл бұрын
More than how to debug that problem, But solution so minimal and powerful.
@TECHSCHOOLGURU
@TECHSCHOOLGURU Жыл бұрын
Thanks!
@dilshataliev
@dilshataliev 2 жыл бұрын
Awesome course, thanks a lot, keep up the good work!
@TECHSCHOOLGURU
@TECHSCHOOLGURU 2 жыл бұрын
Thanks, will do!
@mcgam3r_tv809
@mcgam3r_tv809 Жыл бұрын
Very helpful video. for some reason my fmt.Println() is not printing.
@昆仑弈客
@昆仑弈客 3 жыл бұрын
for now, i can not understand why the condiction is arg.FromAccountID > arg.ToAccountID, i think the accountid is unorderly.
@shalsteven
@shalsteven 3 жыл бұрын
it is used just to make a consistent order. let's say arg.FromAccountID=2 and arg.ToAccountID=10. therefore by using this checking condition if arg.FromAccountID < arg.ToAccountID: both Tx1 and Tx2 will update the account with account_id=FromAccountID first then account with account_id=ToAccountID, not Tx1 update the the account with account_id=FromAccountID first then account with account_id=ToAccountID and Tx2 update the account with account_id=ToAccountIDfirst then account with account_id=FromAccountID let's say arg.FromAccountID=100 and arg.ToAccountID=20. therefore by using this checking condition if arg.FromAccountID < arg.ToAccountID: both Tx1 and Tx2 will update the account with account_id=ToAccountIDfirst then account with account_id=FromAccountID you can see that both Tx1 and Tx2 will update the account in the same order, so there isn't any deadlock
@kertkukk
@kertkukk 4 ай бұрын
The comparison will consistently determine which one to process first, regardless of how they're stored in the database or which one is the sender or receiver of a given transaction.
@alexandervasilenko7773
@alexandervasilenko7773 4 жыл бұрын
Cool! Thanx a lot man!! Good series!!!
@TECHSCHOOLGURU
@TECHSCHOOLGURU 4 жыл бұрын
Thanks, Alex!
@sarthakmaster6797
@sarthakmaster6797 3 жыл бұрын
Awesome, got to learn a lot today👌🏻nice work, please keep up with your work.
@TECHSCHOOLGURU
@TECHSCHOOLGURU 3 жыл бұрын
Happy to hear that!
@yannrolland543
@yannrolland543 2 жыл бұрын
Thanks, very clear!
@TECHSCHOOLGURU
@TECHSCHOOLGURU 2 жыл бұрын
Great to hear!
@danielniels22
@danielniels22 23 күн бұрын
what if the account ID is not in sequential number? like UUID, or like random numbers?
@bergeter5101
@bergeter5101 4 жыл бұрын
excellent explanation! how do you clean data that made from unit test? is it not conflict / make another test failed when the record already exist? im studying how to make test with real database interaction (not with mock). I had looked into datadog go-txdb, seems promising
@TECHSCHOOLGURU
@TECHSCHOOLGURU 4 жыл бұрын
I don't need to clean test data because they are generated randomly, so they won't conflict with each other. You can checkout this video about writing unit tests: kzbin.info/www/bejne/ppmrdZmFfadlhrc
@dangbey4822
@dangbey4822 2 жыл бұрын
If update has no correlation with foreign keys it will not block other channels yes? is not there something also like "NO KEY" for update?
@jarriabidi1438
@jarriabidi1438 4 жыл бұрын
Great content. If you could make a larger go http service and show some design patterns that would be great
@TECHSCHOOLGURU
@TECHSCHOOLGURU 4 жыл бұрын
Thanks, Jarri. That's in the plan!
@innovafrique
@innovafrique 4 жыл бұрын
Thanks a lot. How to make transaction with go for Mongodb ???
@TECHSCHOOLGURU
@TECHSCHOOLGURU 4 жыл бұрын
Good suggestion, Shukuru! But it might be out of scope for this course. I will consider making a video about it in another series.
@luisweck5285
@luisweck5285 Жыл бұрын
how to avoid this deadlock is the ID is a uuid, for example?
@TECHSCHOOLGURU
@TECHSCHOOLGURU Жыл бұрын
It's the same, you can compare UUIDs as well.
@luisweck5285
@luisweck5285 Жыл бұрын
@@TECHSCHOOLGURU i guess one can sort them lexicographically. That makes sense. I was thinking that because UUID v4 don't have an inherent ordering, I would not be able to compare them with anything other than the equals operator
@danielniels22
@danielniels22 23 күн бұрын
@@luisweck5285 i still don't understand. how do we solve it?
@ajf
@ajf 4 жыл бұрын
nice I like your channel
@TECHSCHOOLGURU
@TECHSCHOOLGURU 4 жыл бұрын
Thanks!
@Aleksei-n6h
@Aleksei-n6h Жыл бұрын
Why do you show us the rest of the screen
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,3 МЛН
Disrespect or Respect 💔❤️
00:27
Thiago Productions
Рет қаралды 42 МЛН
[Backend #3] How to write & run database migration in Golang
9:52
Go application setup with PostgreSQL, sqlx, goose migrations
9:38
Make Programming Fun Again
Рет қаралды 8 М.
CQRS Meets Modern Java | Simon Martinelli
23:09
XtremeJ Conference
Рет қаралды 251
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,3 МЛН