Files
progcode/web/public/assets/editorial/2021/transaction-isolation-matrix-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

59 lines
5.0 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 1180" role="img" aria-labelledby="title desc">
<title id="title">Матрица изоляции PostgreSQL 13 для учебного выбора границы</title>
<desc id="desc">Вертикальная матрица сопоставляет Read Committed, Repeatable Read и Serializable в PostgreSQL 13. Для каждого уровня показаны момент snapshot, основная граница и требование к обработке конфликта. Внизу отмечено, что SELECT FOR UPDATE — отдельный способ ограничить доступ к возвращённым строкам, а не лучший уровень изоляции.</desc>
<style>
.bg { fill: #f6f8fb; }
.panel { fill: #ffffff; stroke: #d9e1ec; stroke-width: 2; }
.blue { fill: #eaf3ff; stroke: #2c6ebd; stroke-width: 2; }
.violet { fill: #f2edff; stroke: #7058b5; stroke-width: 2; }
.green { fill: #effaf3; stroke: #2a8f5b; stroke-width: 2; }
.ink { fill: #15263b; }
.sub { fill: #52657b; }
.accent { fill: #234a78; }
text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
.title { font-size: 31px; font-weight: 700; }
.lead { font-size: 20px; }
.head { font-size: 25px; font-weight: 700; }
.label { font-size: 20px; font-weight: 700; }
.body { font-size: 19px; }
.small { font-size: 18px; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 18px; }
</style>
<rect class="bg" width="720" height="1180" rx="26"/>
<rect x="32" y="28" width="656" height="120" rx="18" class="panel"/>
<text x="60" y="74" class="title ink">PostgreSQL 13: изоляция — не рейтинг</text>
<text x="60" y="108" class="lead sub">Сначала назвать инвариант и конфликт, затем выбрать</text>
<text x="60" y="133" class="lead sub">границу, retry или явную блокировку.</text>
<rect x="32" y="178" width="656" height="218" rx="18" class="blue"/>
<text x="60" y="220" class="head ink">Read Committed — default</text>
<text x="60" y="254" class="body ink">Snapshot: начало каждого statement.</text>
<text x="60" y="286" class="body ink">Сильная сторона: простой predetermined row update.</text>
<text x="60" y="318" class="body ink">Риск: несколько statements видят разные committed state.</text>
<text x="60" y="357" class="small sub">Для cross-row правила нужен дополнительный protocol,</text>
<text x="60" y="381" class="small sub">а не надежда, что два SELECT увидят одно и то же.</text>
<rect x="32" y="420" width="656" height="218" rx="18" class="violet"/>
<text x="60" y="462" class="head ink">Repeatable Read</text>
<text x="60" y="496" class="body ink">Snapshot: первый query или data change в transaction.</text>
<text x="60" y="528" class="body ink">Сильная сторона: стабильное представление для чтений.</text>
<text x="60" y="560" class="body ink">Граница: serialization failure возможен; нужен полный retry.</text>
<text x="60" y="599" class="small sub">В PostgreSQL 13 phantom reads не допускаются,</text>
<text x="60" y="623" class="small sub">но serialization anomaly всё ещё возможна.</text>
<rect x="32" y="662" width="656" height="236" rx="18" class="green"/>
<text x="60" y="704" class="head ink">Serializable</text>
<text x="60" y="738" class="body ink">Committed result эквивалентен некоторому serial order.</text>
<text x="60" y="770" class="body ink">Граница: конфликт может отменить один transaction.</text>
<text x="60" y="802" class="body ink">Обработка: retry whole transaction после SQLSTATE 40001.</text>
<text x="60" y="841" class="small sub">Это не «лучший» уровень: он стоит monitoring и retry,</text>
<text x="60" y="865" class="small sub">а пригодность зависит от операции и её side effects.</text>
<rect x="32" y="926" width="656" height="182" rx="18" fill="#172b45"/>
<text x="60" y="970" class="head" fill="#ffffff">Отдельный инструмент: SELECT ... FOR UPDATE</text>
<text x="60" y="1006" class="body" fill="#dbe8f5">В PostgreSQL он блокирует writers и lockers</text>
<text x="60" y="1035" class="body" fill="#dbe8f5">на возвращённых строках до конца transaction.</text>
<text x="60" y="1072" class="small" fill="#dbe8f5">Он работает только с выбранным scope и protocol всех writers;</text>
<text x="60" y="1098" class="small" fill="#dbe8f5">не заменяет формулировку инварианта или интеграционный test.</text>
</svg>