Two Phase Commit - Giao dịch phân tán | Phỏng vấn Thiết kế Hệ thống từ 0 đến 1 với cựu Kỹ sư phần mềm Google

Tác giả: Jordan has no life
Ngày xuất bản: 2023-05-21T00:00:00
Length: 08:19

Anyone in the 3% of my viewership looking for me to two phase commit to them?

Thanks @Cricket for bringing this up. I'll add this here since I think this is cool.

It's also worth mentioning three phase commit. In a three phase commit, instead of just sending messages to our participant nodes twice, we add a middle stage called "prepare to commit" which the coordinator sends out after all the participants respond "OK" in the prepare stage. Now, if the coordinator goes down in the last stage of 3PC, the participant nodes can query one another and see that at least one node had "prepare to commit" status, meaning that they should all commit the transaction. If they decide together (probably requires distributed consensus) that none of them had "prepared to commit" status, they can then abort the transaction. Now, in the event that a coordinator node goes down, we can actually recover. Note that if a participant goes down, we still need to keep trying to write to it forever.

Saga commits seem to be a bit of a different thing, and the concept is more so that instead of attempting to write to many nodes at once, write them one at a time, and if some of the writes fail, attempt to perform a separate "compensating transaction" in order to revert that write and bring the database back to its old state. Obviously here you run the risk of that revert failing.

Dịch Vào Lúc: 2025-03-13T08:18:44Z

Yêu cầu dịch (Một bản dịch khoảng 5 phút)

Phiên bản 3 (ổn định)

Tối ưu hóa cho một người nói. Phù hợp cho video chia sẻ kiến thức hoặc giảng dạy.

Video Đề Xuất