Files
progcode/web/public/assets/editorial/2021/transaction-conflict-diagnosis-2021.svg
T
huncode 323d80b188
Build and deploy / deploy (push) Successful in 14s
revise January 2021 transaction articles
2026-07-31 12:13:15 +03:00

73 lines
5.2 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 1210" role="img" aria-labelledby="title desc">
<title id="title">Диагностика конфликта транзакций по симптому, причине, проверке и действию</title>
<desc id="desc">Вертикальная схема связывает четыре симптома конкурентного конфликта: раздельные чтение и запись, неполный набор строк, блокировку в разном порядке и serialization failure. Для каждого показаны причина, точная проверка и безопасное следующее действие.</desc>
<style>
.bg { fill: #f6f8fb; }
.panel { fill: #ffffff; stroke: #d9e1ec; stroke-width: 2; }
.issue { fill: #fff0f0; stroke: #d9534f; stroke-width: 2; }
.check { fill: #fff8e7; stroke: #c38a17; stroke-width: 2; }
.action { fill: #effaf3; stroke: #2a8f5b; stroke-width: 2; }
.ink { fill: #15263b; }
.sub { fill: #52657b; }
text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
.title { font-size: 27px; font-weight: 700; }
.lead { font-size: 19px; }
.head { font-size: 23px; font-weight: 700; }
.label { font-size: 19px; font-weight: 700; }
.body { font-size: 18px; }
.small { font-size: 17px; }
</style>
<rect class="bg" width="720" height="1210" rx="26"/>
<rect x="32" y="28" width="656" height="120" rx="18" class="panel"/>
<text x="60" y="70" class="title ink">Конфликт: не угадываем, а сужаем границу</text>
<text x="60" y="105" class="lead sub">Карточка связывает: симптом → причина</text>
<text x="60" y="132" class="lead sub">→ проверка → действие.</text>
<rect x="32" y="182" width="656" height="202" rx="18" class="issue"/>
<text x="60" y="222" class="head ink">1. Оба запроса «успешны», правило нарушено</text>
<text x="60" y="254" class="body ink">Причина: read и write не закрыли один shared invariant.</text>
<rect x="60" y="279" width="282" height="76" rx="10" class="check"/>
<text x="78" y="310" class="label ink">Проверка</text>
<text x="78" y="338" class="small ink">Назвать rows и predicate</text>
<rect x="374" y="279" width="282" height="76" rx="10" class="action"/>
<text x="392" y="310" class="label ink">Действие</text>
<text x="392" y="338" class="small ink">Поместить их в one boundary</text>
<path d="M360 384 L360 420" stroke="#7f91a8" stroke-width="4" marker-end="url(#arrow)"/>
<rect x="32" y="438" width="656" height="202" rx="18" class="issue"/>
<text x="60" y="478" class="head ink">2. FOR UPDATE есть, но scope не совпадает</text>
<text x="60" y="510" class="body ink">Причина: locked only one row, а predicate читает many rows.</text>
<rect x="60" y="535" width="282" height="76" rx="10" class="check"/>
<text x="78" y="566" class="label ink">Проверка</text>
<text x="78" y="594" class="small ink">Сопоставить query и invariant</text>
<rect x="374" y="535" width="282" height="76" rx="10" class="action"/>
<text x="392" y="566" class="label ink">Действие</text>
<text x="392" y="594" class="small ink">Зафиксировать полный row set</text>
<path d="M360 640 L360 676" stroke="#7f91a8" stroke-width="4" marker-end="url(#arrow)"/>
<rect x="32" y="694" width="656" height="202" rx="18" class="issue"/>
<text x="60" y="734" class="head ink">3. Операция ждёт или получила deadlock</text>
<text x="60" y="766" class="body ink">Причина: two transactions ask multiple objects in different order.</text>
<rect x="60" y="791" width="282" height="76" rx="10" class="check"/>
<text x="78" y="822" class="label ink">Проверка</text>
<text x="78" y="850" class="small ink">Записать order и transaction scope</text>
<rect x="374" y="791" width="282" height="76" rx="10" class="action"/>
<text x="392" y="822" class="label ink">Действие</text>
<text x="392" y="850" class="small ink">Один order; retry abort only</text>
<path d="M360 896 L360 932" stroke="#7f91a8" stroke-width="4" marker-end="url(#arrow)"/>
<rect x="32" y="950" width="656" height="202" rx="18" class="issue"/>
<text x="60" y="990" class="head ink">4. Serializable вернул SQLSTATE 40001</text>
<text x="60" y="1022" class="body ink">Причина: engine rejected a dangerous read/write pattern.</text>
<rect x="60" y="1047" width="282" height="76" rx="10" class="check"/>
<text x="78" y="1078" class="label ink">Проверка</text>
<text x="78" y="1106" class="small ink">Не published side effect before commit</text>
<rect x="374" y="1047" width="282" height="76" rx="10" class="action"/>
<text x="392" y="1078" class="label ink">Действие</text>
<text x="392" y="1106" class="small ink">Retry whole transaction</text>
<defs>
<marker id="arrow" markerWidth="10" markerHeight="10" refX="7" refY="3" orient="auto"><path d="M0,0 L0,6 L8,3 z" fill="#7f91a8"/></marker>
</defs>
</svg>