{"id":27,"date":"2026-12-01T20:10:11","date_gmt":"2026-12-01T20:10:11","guid":{"rendered":"https:\/\/voidlabs.wpenginepowered.com\/?p=27"},"modified":"2026-12-01T20:10:11","modified_gmt":"2026-12-01T20:10:11","slug":"the-deadlock-hydra","status":"publish","type":"post","link":"https:\/\/dndc.quest\/?p=27","title":{"rendered":"The Deadlock Hydra"},"content":{"rendered":"\n<div class=\"wp-block-group ddc-statcard ddc-boss is-layout-flow wp-block-group-is-layout-flow\">\n<dl class=\"ddc-readout\"><div class=\"ddc-row\"><dt>Layer<\/dt><dd>3. The Database Depths<\/dd><\/div><div class=\"ddc-row\"><dt>Type<\/dt><dd>Layer Boss<\/dd><\/div><div class=\"ddc-row\"><dt>Uptime<\/dt><dd>450 per head<\/dd><\/div><div class=\"ddc-row\"><dt>Latency<\/dt><dd>\u221e (each head is waiting for the other)<\/dd><\/div><div class=\"ddc-row ddc-meter\"><dt>Threat Level<\/dt><dd><span class=\"ddc-bar\" style=\"--ddc-fill:80%\" aria-hidden=\"true\"><\/span><span class=\"ddc-stars\">\u2605\u2605\u2605\u2605\u2606<\/span><\/dd><\/div><\/dl>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Lore<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Deadlock Hydra has two heads, and both are extremely polite. The left head holds the <code>orders<\/code> table and won&#8217;t let go until the right head releases <code>inventory<\/code>. The right head holds <code>inventory<\/code> and won&#8217;t let go until the left head releases <code>orders<\/code>. &#8220;After you,&#8221; says one. &#8220;No, after <em>you<\/em>,&#8221; says the other. They have been saying this since 2019. Meanwhile, every request in the Realm queues up behind them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to defeat it<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Kill one transaction so the other can finish.<\/strong> Sever one head and the other immediately completes its work and wanders off, satisfied.<\/p>\n\n\n\n<div class=\"wp-block-group ddc-tip is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Real-world tip:<\/strong> A deadlock happens when two database transactions each lock something the other needs, so neither can continue. MySQL usually detects this and cancels one of them automatically, and the app should simply retry it. Frequent deadlocks point to code that locks tables in different orders or holds transactions open too long. Keeping transactions short and always locking in the same order prevents most of them.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Boss of the Database Depths. Two heads, each waiting for the other to move, and neither ever will.<\/p>\n","protected":false},"author":2,"featured_media":59,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,16],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bestiary","category-database-depths"],"_links":{"self":[{"href":"https:\/\/dndc.quest\/index.php?rest_route=\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dndc.quest\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dndc.quest\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dndc.quest\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dndc.quest\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27"}],"version-history":[{"count":1,"href":"https:\/\/dndc.quest\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions"}],"predecessor-version":[{"id":83,"href":"https:\/\/dndc.quest\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions\/83"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dndc.quest\/index.php?rest_route=\/wp\/v2\/media\/59"}],"wp:attachment":[{"href":"https:\/\/dndc.quest\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dndc.quest\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dndc.quest\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}