Write-ahead log

선행 기록 로그

Record a change durably before modifying its data page.

···
html
<div class="demo"><div class="head"><b>WRITE-AHEAD LOG</b><span>UPDATE balance</span></div><div class="stage wal"><div class="step cell">1 · WAL</div><div class="step cell">2 · commit</div><div class="step cell">3 · page</div></div><div class="foot"><span id="walstatus">log record written first</span><span>crash → replay</span></div></div>
css
*{box-sizing:border-box}.demo{width:min(96vw,820px);height:min(94vh,350px);padding:clamp(8px,2vmin,18px);border:1px solid var(--line);border-radius:14px;background:var(--surface);color:var(--fg);display:flex;flex-direction:column;gap:clamp(5px,1.5vmin,12px);font:600 clamp(12px,3.5vmin,15px)/1.25 var(--font-sans),sans-serif;overflow:hidden}.head,.foot,.row{display:flex;justify-content:space-between;align-items:center;gap:8px}.head b{color:var(--accent)}.head span,.foot,.muted{color:var(--muted)}.stage{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;gap:8px}.cell,.pill{border:1px solid var(--line);border-radius:8px;background:var(--bg);padding:clamp(4px,1.2vmin,9px);text-align:center}.pill{border-radius:999px}.on{border-color:var(--accent)!important;background:color-mix(in srgb,var(--accent) 17%,var(--surface))!important;color:var(--fg)!important}.bad{border-color:#e16a5d!important;background:color-mix(in srgb,#e16a5d 18%,var(--surface))!important}.foot{font-size:clamp(12px,3vmin,14px)}.wal{justify-content:space-around}.wal .step{min-width:27%;transition:.25s}@media(max-width:400px){.wal{gap:3px}.wal .step{min-width:30%;padding:3px}}
js
let n=0;const s=['log record written first','commit acknowledged','data page updated'];function tick(){document.querySelectorAll('.wal .step').forEach((e,i)=>e.classList.toggle('on',i<=n));document.getElementById('walstatus').textContent=s[n];n=(n+1)%3}tick();const t=setInterval(tick,1050);document.querySelector('.demo').onclick=()=>{clearInterval(t);tick()}

A write-ahead log (WAL) stores a change record before updating a data page. After a crash, the database can replay committed changes from the log.

The demo shows log write, commit, and page update in order. Durability settings and checkpoints affect performance and recovery time; WAL files alone are not a complete backup strategy.

When to use

Trace WAL when investigating recovery, replication lag, or write performance.

Open as page ↗