what is OPTIMISTIC LOCK?

learn how and when to use pessimistic and optimistic locks !!
how Wikipedia document editing is locked using optimistic locks
#pessimisticlocks #optimisticlocks
#systemdesigntips #systemdesign #computerscience #learnsystemdesign #interviewpreperation #amazoninterview #googleinterview #uberinterview #micrsoftinterview

Пікірлер: 63

  • @NaturalPro100
    @NaturalPro1005 жыл бұрын

    Amazing explanation.Thanks :)

  • @jksharma7
    @jksharma74 жыл бұрын

    my friend you are so GREAT !!

  • @mallikarijit
    @mallikarijit5 жыл бұрын

    Thanks, Narendra! Your tutorials have always been good.

  • @srikanthrachala
    @srikanthrachala4 жыл бұрын

    Very nice and detailed explanation !!. Thank you

  • @atexnik
    @atexnik4 жыл бұрын

    Clear explanation! Thanks.

  • @truongquochung4858
    @truongquochung48582 жыл бұрын

    What an excellent video! You explaination is very perspicuous and examples are very practicle. Keep going! 😉

  • @RussianCyclop
    @RussianCyclop Жыл бұрын

    Great explanation, thank you sir.

  • @adanarreola272
    @adanarreola2723 жыл бұрын

    Very well explained!

  • @ypucandeleteit
    @ypucandeleteit3 жыл бұрын

    awesome explanation. I will save this video for the next time I need to check this out. The rule of thumb is a lifesaver as well

  • @adamhughes9938
    @adamhughes99383 жыл бұрын

    Great as usual

  • @rettipatti
    @rettipatti2 жыл бұрын

    Good explanation!

  • @user-pn8vw8rr3m
    @user-pn8vw8rr3m5 жыл бұрын

    Interesting and clear as usual! Thank you, Narendra!

  • @sharatchandra9198
    @sharatchandra91983 жыл бұрын

    very clear and concise

  • @shivendrakadam7596
    @shivendrakadam75965 жыл бұрын

    Awesome!!! Please keep uploading videos. They are helping a lot...!!!!:)

  • @connect2rajib

    @connect2rajib

    5 жыл бұрын

    Yah right.u r doing a fantastic job for free.plz keep it up. We r really grateful......its really helps.sharing is caring.

  • @CodingWorldWithNinja
    @CodingWorldWithNinja3 жыл бұрын

    thanks Narendra i helps a lot me to understand locks on DB

  • @logicboard7746
    @logicboard77462 жыл бұрын

    clear like water! thanks bro!

  • @kaushikmitra1982
    @kaushikmitra198211 ай бұрын

    Nice video!!!

  • @80kg
    @80kg2 жыл бұрын

    great content thank you sir

  • @PratikPatel-fg9xe
    @PratikPatel-fg9xe Жыл бұрын

    Great explanation 👍

  • @priyankawagh5217
    @priyankawagh52174 жыл бұрын

    Thanks!

  • @fairytalesnew
    @fairytalesnew3 жыл бұрын

    Hi sir i have seen one of your video related to transactions(WAL) can you create one video which can explain the relation between the locks used by transactions and optimistic and pessimistic locks(actual question is why we need these optimistic and pessimistic locking if we already have transaction isolation levels)

  • @sayantanray9595
    @sayantanray95954 жыл бұрын

    Nice explanation

  • @ravikiranbcm
    @ravikiranbcm Жыл бұрын

    nice

  • @soufianeodf9125
    @soufianeodf91253 жыл бұрын

    good content

  • @abhishekkumar9812
    @abhishekkumar98124 жыл бұрын

    Hi Narendra, thank you very much Narendra. These videos are really helpful. Could please make some video on System design of paytm or phonePe or googlePay ? it would be a great help to many of us .

  • @postman12
    @postman123 жыл бұрын

    thumbs up

  • @abhijitprusty
    @abhijitprusty3 жыл бұрын

    How to handle conflicts in case of optimistic locks ?

  • @PANKAJSINGH-lv7iu
    @PANKAJSINGH-lv7iu3 жыл бұрын

    If an optimistrick exception is raised then what we do. Can we write some sort of retry logic for the same transaction ??

  • @thiwanka.w92
    @thiwanka.w922 жыл бұрын

    Interesting

  • @marriagedance8657
    @marriagedance86574 жыл бұрын

    Why optimistic is even termed as a lock?

  • @mr-engineer
    @mr-engineer4 жыл бұрын

    Awesome! Thanks for a really clear explanation.

  • @sanatandharmu
    @sanatandharmu3 жыл бұрын

    Please use a good sound recording device, the sound is suppressed with lot of noise.

  • @boteliu6498
    @boteliu64983 жыл бұрын

    So optimistic lock also need a lock before verifying version and updating data, but lock period is shorter, right?

  • @TamilTV2
    @TamilTV24 ай бұрын

    8.40 Rq 1 finishes last, Rq 2 finishes first ... how to find the latest data? will it not be wrong to change 17 to 14?

  • @amanshivhare5592
    @amanshivhare55923 жыл бұрын

    When there are very few clahes, how optimistic lock is more useful, wouldn't pessimistic be useful? As no-other can edit but read, as there are less clashes, there will be no one updating so we can lock. ? I am bit confused.

  • @satishgarepalli5977
    @satishgarepalli59774 жыл бұрын

    could please explain what is a live lock mean??

  • @at_tap
    @at_tap5 жыл бұрын

    optimistic or pessimistic locks are application level decision, so saying that pessimistic locks are for RDBMS is not right. You can pessimistic locks implemented in NoSQL DB, same ways optimistic in RDBMS.

  • @MaxPicAxe
    @MaxPicAxe2 жыл бұрын

    But with optimistic lock you still have to perform an atomic read and write (read version to check, and then update version and write new data within same transaction). So I don't understand the point. Am I misunderstanding something? Edit: Oh I see, you only acquire the lock when you are done processing the new data that should be written. I would have thought that's how people always did it.

  • @pramodrawat9113
    @pramodrawat91135 жыл бұрын

    how to handle OPTIMISTIC LOCKING with shading and clusters ?

  • @charliezhang807
    @charliezhang8074 жыл бұрын

    Thanks for the video. One question: assuming version 1 data is n, process 1(want to +1) and 2 (want to +2) both validate that it is safe to write since version has not changed, the slow writer will operate on stale data(since the fast writer finishes writing first). How do optimistic locking solve this issue?

  • @rufusli7056

    @rufusli7056

    4 жыл бұрын

    Charlie Zhang Both processes will read the data at version 1, write the new value into their own write buffer in parallel. However at commit stage, one of the processes will succeed in updating the data, which will be the version after the commit. and another process will be aborted because it read data at version 1 which does not match version at commit time and have to retry its transaction

  • @niloysaha3229
    @niloysaha32295 жыл бұрын

    Question : How optimistic lock handles concurrency? If multiple threads are trying to update against a same version number then how the correctness of the system will retain?

  • @TechDummiesNarendraL

    @TechDummiesNarendraL

    5 жыл бұрын

    You will need to use pessimistic lock/ transaction there. Because you are reading n updating.

  • @varunvats32

    @varunvats32

    5 жыл бұрын

    Apart from pessimistic locking way, this can be achieved by optimistic locking also, you can read about MVCC. Many DBs like Postgress uses this approach.

  • @SteelersRock1190

    @SteelersRock1190

    4 жыл бұрын

    My team generally handles it with some sort of retry policy wrapping the processes which also enforce some basic validations. If the update fails since some other process concurrently updated the record, then you need to re-read the record and then if the update is no longer safe, it should be enforced by the common set of validations that each process would have had to enforce.

  • @oopsywtf
    @oopsywtf5 жыл бұрын

    How can optimistic lock solve the problem of 2 or more concurrent connections not updating the version to a different one after checking the versions simultaneously ?

  • @TechDummiesNarendraL

    @TechDummiesNarendraL

    5 жыл бұрын

    There will be a local transaction which stops from version conflicts

  • @SteelersRock1190
    @SteelersRock11904 жыл бұрын

    Aren't the concepts really more of "Pessimistic locking" and "Optimistic concurrency"? I've never heard it referred to as Optimistic locking since the whole point is that it's not locking but rather validating that the mutation is still safe based on criteria like versioning.

  • @amitk6701

    @amitk6701

    4 жыл бұрын

    Well, my first reaction here was "its lock, not control whether pessimistic or optimistic" but as more I explored, yeah this is the case - "Pessimistic locking" and "Optimistic concurrency (control mechanism with versioning, if you will)". Yep!

  • @viputdBeast
    @viputdBeast4 жыл бұрын

    When we use frameworks like rails and start a transaction, like ActiveRecord::Base.transaction should it not acquire locks by default on the affected rows.? My question why transactions and acquiring locks cant go hand in hand ?

  • @natewallis1

    @natewallis1

    6 ай бұрын

    Surely it depends on your use case (which he explains in the video). You can get locks on anything, but should you? What impact will that have on your users?

  • @rohanbundelkhandi3202
    @rohanbundelkhandi32024 жыл бұрын

    Please make video on: System Design of Version Control System like git

  • @mohammedamenuddin3675
    @mohammedamenuddin36754 жыл бұрын

    Very clear . Thanks . Does pessimistic lock require version and timestamp . If yes then why

  • @darksteam999

    @darksteam999

    7 ай бұрын

    No, because the editing thread will lock that record and the other thread that is trying to edit it as well will get blocked. The optimistic locking requires a version (or timestamp) to do the rollback of that active transaction

  • @ariellyrycs
    @ariellyrycs4 жыл бұрын

    I @tech Dummies, i'm a front-end developer, i got a look question in my system design and i wasn't able to answer it. do you think is something that can affect my interview result?

  • @TechDummiesNarendraL

    @TechDummiesNarendraL

    4 жыл бұрын

    If you are not a full stack developer, I don't see a point in asking system design question. But I would expect you to understand Design patterns

  • @puneet6896
    @puneet68963 жыл бұрын

    Audio quality is not good.

  • @yashprajapati4061
    @yashprajapati406127 күн бұрын

    come on man, please listen to your video, do some editing before uploading

  • @amareshsat
    @amareshsat3 жыл бұрын

    Didn't like

  • @mattbrody1424
    @mattbrody14242 жыл бұрын

    Man "kind of..." "like..." .etc are not precise technical terms...contention would do the job, concurrency etc your tutorial is mediocre in terms of quality of explaining those important topics in a succinct and clear technical terms.

  • @mattbrody1424
    @mattbrody14242 жыл бұрын

    How do you know that pessimistic lock is mostly used ? Do you have any data, stats to prove it ? I guess not...so you statement is not valid, sucks ok, ok....ok :-)