နားလည်ထားရမယ့် အချက်
MVCC ကြောင့် reader နဲ့ writer အများစုက တစ်ယောက်ကိုတစ်ယောက်ပိတ်မထားဘဲ snapshot များဖြင့်အလုပ်လုပ်နိုင်ပါတယ်။ Read Committed က statement တစ်ခုစီအတွက် snapshot အသစ်ယူပြီး Repeatable Read က transaction အတွင်း stable snapshot ပေးပါတယ်။ Serializable က anomaly မဖြစ်စေရန် transaction ကို abort/retry ခိုင်းနိုင်ပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Terminal နှစ်ခုဖြင့် transaction တစ်ခုက row update မcommit သေးချိန်မှာ တစ်ခုက old version ကိုဖတ်နိုင်တာစမ်းမယ်။ Isolation level ကို “ပိုမြင့်တာအမြဲကောင်း” လို့မရွေးဘဲ invariant၊ contention နဲ့ retry handling ကိုအတူသတ်မှတ်ပါ။
အတူတူ စမ်းရေးကြည့်မယ်
-- Session A
BEGIN;
UPDATE app.users SET display_name = 'Uncommitted' WHERE user_id = 1;
-- Session B (still sees the committed version)
SELECT display_name FROM app.users WHERE user_id = 1;
-- Session A
COMMIT;
-- For stronger semantics:
BEGIN ISOLATION LEVEL SERIALIZABLE;Uncommitted change ကို တခြား session မမြင်သေးကြောင်း စမ်းသပ်နိုင်မည်။၅ မိနစ် စမ်းကြည့်
Read Committed နဲ့ Repeatable Read အောက်တွင် query တစ်ခုကိုနှစ်ခါ run ပြီး concurrent update နောက် result ကွာခြားမှုစစ်ပါ။
သတိလေးတစ်ချက်
Serializable သုံးရုံနဲ့ application logic ပြီးပြည့်စုံမလာပါ—serialization failure retry loop မရှိရင် request fail ပါမယ်။
PostgreSQL — Concurrency Control — PostgreSQL Global Development Group