Implementing Distributed Transactions using Two Phase Commit Protocol

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 61

  • @kunalchhatwani2309
    @kunalchhatwani2309 2 года назад +17

    This channel is a gold mine, appreciate the efforts you put in.👏

  • @sangamsahai9823
    @sangamsahai9823 Год назад +1

    This channel is a gold mine indeed

  • @dasmala9175
    @dasmala9175 2 года назад +4

    Your videos have so much information and to the point details in them, I am lucky that youtube has recommended me your videos

  • @shikharsubedi
    @shikharsubedi 2 месяца назад

    thank you for the code demonstration. it really solidified the understanding. I really need to learn go.

  • @akashshirale1927
    @akashshirale1927 27 дней назад

    Wow!!! Learnt a lot

  • @VimalKumar-rd1ol
    @VimalKumar-rd1ol 2 года назад +4

    Great video, keep adding more videos !

  • @shishirchaurasiya7374
    @shishirchaurasiya7374 Год назад

    Literally this was an amazing hit

  • @abhishek120897
    @abhishek120897 2 года назад +1

    This was top notch, mazza aaya!

  • @moshoaib866
    @moshoaib866 2 года назад +1

    You channel has an addiction. Amazing content, loved it ❤️

  • @xenky0
    @xenky0 Год назад +1

    Good example, nice explanation, thank you.

  • @SwikarP
    @SwikarP 10 месяцев назад

    Thanks awesome! This is high quality explanation.

  • @venkatajagannath6014
    @venkatajagannath6014 2 дня назад

    Thanks a lot for this video, would really love to understand working of @Timer and the nuances of implementing the same. Can you explain that ?

  • @R1996s
    @R1996s Год назад

    Amazing man, just amazing!

  • @udaysolanki3659
    @udaysolanki3659 2 года назад +2

    Awesome Video
    Just to understand payment flow too.
    what should be the order for payment here
    1. Reserve -> Payment-(if payment fails then remove reservation, exit)> Assign (if assign fails then refund)
    2. Success Payment->Reserve(if reserve fails then refund, exit) -> Assign (if assign fails then refund)

    • @AsliEngineering
      @AsliEngineering  2 года назад +1

      Payment flows are slightly different. Depends on the API exposed by then payment gateways.
      They do expose orders which acts as reservations but not concrete like distributed transaction.
      By the way, you should never model payments as a distributed transaction. It is always designed with eventual consistency in mind given how banks work.

  • @abhirupacharya010
    @abhirupacharya010 Год назад

    Absolutely beautiful!!

  • @chineseboycott829
    @chineseboycott829 10 месяцев назад

    Mazaa aa gya bhai sahab

  • @vpk21
    @vpk21 2 года назад +1

    Good video. Looking forward for implementation of Paxos and Raft as well.

  • @architshukla8076
    @architshukla8076 2 года назад +1

    Very Informative channel and content . Keep it Up !! 👏👏👏

  • @NidhiSinghPersonal
    @NidhiSinghPersonal 8 месяцев назад

    This video got me subscribed to your channel, Amazing content. Loved the implementation bit :)

  • @architagrawal5796
    @architagrawal5796 2 года назад

    Appreciate your efforts 👏👏👏

  • @srawat1212
    @srawat1212 Год назад +1

    @AsliEngineering - what if in the placeOrder() we are able to make 3 api calls but the app instance crashes down before we book the agent for the order? I guess this case is not going to be handled.

  • @renbangbprd7236
    @renbangbprd7236 2 месяца назад

    Where is the link to the previous video? I can't seem to find it

  • @gurupreetsingh8347
    @gurupreetsingh8347 Год назад +2

    Thanks nice explaination but how we can implement timer thing..

    • @AsliEngineering
      @AsliEngineering  Год назад +1

      1. Threads and executors 2. Distributed Event Generator 3. Specialised database like Redis

  • @tusharabbott
    @tusharabbott 2 года назад +3

    Great video loved it. btw which vs code theme your are using?

  • @kaal_bhairav_24
    @kaal_bhairav_24 7 месяцев назад

    12:45 order service is acting as an orchestrator [* link: orchestration vs choreography]

  • @GauravSharma-wb9se
    @GauravSharma-wb9se 2 года назад +1

    we can make transaction in only commit phase itself....if both commit phases goes fine then accept order or else throw unacceptable error...…isn't it?

  • @abhiraj533
    @abhiraj533 6 месяцев назад

    Quick question out of curiosity... There are scenarios when 1 agent gets 2 orders due to nearby geological of order delivery address ... How such things can be handled??

    • @vikeshkumar1431
      @vikeshkumar1431 5 месяцев назад

      Delivery service's delivery_agent/reserve api can have this logic in real scenario. And the same api can return the agent id so that the order service can book the same agent in the 2nd phase of the commit

  • @agauniyal
    @agauniyal Год назад +1

    I'm having difficulty understanding, how is the code representing distributed transactions?If I take it on literal face-value, there are no 2 different datasources so current scenario could have been done under same transaction, why going through the pain of taking locks and everything? Distributed transactions are hard because there are 2 or more services/datasources etc which don't share any transaction id/object/etc. This example doesn't fits the scenario.
    Please correct where I'm wrong. Thanks.

    • @AsliEngineering
      @AsliEngineering  Год назад +1

      Distributed does not just mean having two machines. It means having completely isolated processes/threads. The example I took mimics that. You can use this very example across machines and it would work.
      also,.I never ran entrie thing in one transaction.

  • @nontechnicalbaba
    @nontechnicalbaba 2 месяца назад

    Is it synchronous or asynchronous? Is it scalable in real toy environment?

    • @AsliEngineering
      @AsliEngineering  2 месяца назад

      distributed txn have to be synchronous. if you need strong consistency across machines, you have to do this.

  • @shibasispatel6624
    @shibasispatel6624 2 года назад +1

    Could you please explain why did you use Select for update and then update it? I know it will lock that row in a write exclusive lock so that no other transaction can update that row. But what would happen if we directly update that row by using "update agents set is_reserved=true and order_id=1 where is_reserved = false and order_id = null"?

    • @AsliEngineering
      @AsliEngineering  2 года назад +2

      Consider that there is one delivery agent and if we do not lock it then both the transaction might update the same row and both would think that it reserved the agent. In reality one ohs while the other has not.

    • @VikramSingh-oq7pe
      @VikramSingh-oq7pe Год назад

      @@AsliEngineering How does it work in the case of replicas? Let's suppose a transaction updates is_reserved=true but other transactions might read stale data and assign it to some other agent

    • @viewonly_akshay
      @viewonly_akshay Год назад

      I believe, in this case, reading a right state is critical and critical read or writes should go to master instead of read replicas.

    • @mahendrahegde6400
      @mahendrahegde6400 7 месяцев назад +1

      But find and update is atomic so not sure if select for update is really needed here.
      In case of replicated dbs writes go to primary so select for update is run on primary not on secondary

  • @moylababa8196
    @moylababa8196 2 года назад

    awesome content .. could you please suggest some beginner friendly resource?

    • @AsliEngineering
      @AsliEngineering  2 года назад +2

      This is beginner friendly 🙂 would recommend going through it twice or thrice. More importantly prototype it locally.

  • @kushal1
    @kushal1 2 года назад

    Hi Aprit, when we reserve a food packet and delivery agent is not available, then should we not rollback the reservation since the order itself is not placed?

    • @AsliEngineering
      @AsliEngineering  2 года назад

      Yes. We would roll back. Plus the timer would ensure that in case we don't the lock is auto-released.

    • @kushal1
      @kushal1 2 года назад

      @@AsliEngineering Okay

  • @tesla1772
    @tesla1772 2 года назад +1

    Is there an github repo for this code

    • @AsliEngineering
      @AsliEngineering  2 года назад +2

      Don't remember. Check my GitHub profile or description of this video.

  • @hardikpandya3621
    @hardikpandya3621 Год назад

    can you please send the github link of this code

    • @AsliEngineering
      @AsliEngineering  Год назад +1

      There is no GutHub repo holding this code. It was a one time short code that I wrote.

  • @tjLearns-ps3bk
    @tjLearns-ps3bk 6 месяцев назад

    💥

  • @vikramragunathan6392
    @vikramragunathan6392 Год назад

    👌👌

  • @JUNO2206
    @JUNO2206 9 месяцев назад

    Tried 2PC logically However, it's difficult in practice.

  • @AshishDoneriya
    @AshishDoneriya Год назад +2

    both parts of videos could have been under 30 min (total) if there is no repetitive talk.

  • @a.nk.r7209
    @a.nk.r7209 2 года назад

    I've fallen to the right place probably 🤷🏽