[{"data":1,"prerenderedAt":78},["ShallowReactive",2],{"term-l\u002Flocking":3,"related-l\u002Flocking":60},{"id":4,"title":5,"acronym":6,"body":7,"category":40,"description":41,"difficulty":42,"extension":43,"letter":44,"meta":45,"navigation":46,"path":47,"related":48,"seo":54,"sitemap":55,"stem":58,"subcategory":6,"__hash__":59},"terms\u002Fterms\u002Fl\u002Flocking.md","Locking",null,{"type":8,"value":9,"toc":33},"minimark",[10,15,19,23,26,30],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"Locking prevents two transactions from modifying the same data at the same time. It is how databases coordinate concurrent access. Too little locking causes corrupted data. Too much locking causes slow performance and potential deadlocks. Finding the balance is the art.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Locking is a concurrency control mechanism that prevents multiple transactions from accessing or modifying the same data simultaneously in conflicting ways. Databases use row-level, page-level, and table-level locks. Lock types include shared (read), exclusive (write), and intent locks. Lock management is automatic in most transactions.",[11,27,29],{"id":28},"when-youll-hear-this","When You'll Hear This",[16,31,32],{},"\"The long-running report query is holding a lock that's blocking the payment transaction.\" \u002F \"Use the lowest lock level that still protects your data.\"",{"title":34,"searchDepth":35,"depth":35,"links":36},"",2,[37,38,39],{"id":13,"depth":35,"text":14},{"id":21,"depth":35,"text":22},{"id":28,"depth":35,"text":29},"database","Locking prevents two transactions from modifying the same data at the same time. It is how databases coordinate concurrent access.","advanced","md","l",{},true,"\u002Fterms\u002Fl\u002Flocking",[49,50,51,52,53],"Optimistic Locking","Pessimistic Locking","Deadlock","Transaction","Race Condition",{"title":5,"description":41},{"changefreq":56,"priority":57},"weekly",0.7,"terms\u002Fl\u002Flocking","UeDPRmLKEeNAlTmPi-usIIQQbYU6BGi4ETqssoXpgV8",[61,66,69,72,75],{"title":51,"path":62,"acronym":6,"category":63,"difficulty":64,"description":65},"\u002Fterms\u002Fd\u002Fdeadlock","general","intermediate","A deadlock is when two things are each waiting for the other to go first, and neither ever does. Thread A holds Lock 1 and wants Lock 2.",{"title":49,"path":67,"acronym":6,"category":40,"difficulty":42,"description":68},"\u002Fterms\u002Fo\u002Foptimistic-locking","Optimistic locking assumes conflicts are rare so it does not lock the row upfront. Instead, it adds a version number to each row.",{"title":50,"path":70,"acronym":6,"category":40,"difficulty":42,"description":71},"\u002Fterms\u002Fp\u002Fpessimistic-locking","Pessimistic locking assumes conflicts are likely, so it locks the row the moment you read it. Nobody else can touch it until you are done.",{"title":53,"path":73,"acronym":6,"category":63,"difficulty":64,"description":74},"\u002Fterms\u002Fr\u002Frace-condition","A race condition is when two parts of your code are racing to do something at the same time and the winner isn't guaranteed — leading to unexpected, hard-t...",{"title":52,"path":76,"acronym":6,"category":40,"difficulty":64,"description":77},"\u002Fterms\u002Ft\u002Ftransaction","A transaction groups multiple database operations into one all-or-nothing bundle. Either ALL of them succeed, or NONE of them happen.",1776518293084]