लेखनाग्रधर्मः। घटनास्रोते (२५ अक्टो) domain इतिहासः। अत्र engine कथं durably लिखति। WAL, fsync, checkpoint। न केवलं app log; लेखनाग्रधर्मः।
English (minimizable)
After event sourcing (25 Oct), this post covers write-ahead logs inside storage engines: intent-before-mutate, fsync barriers, group commit, checkpoints, checksums, redo or undo policy, replica apply order and how WAL differs from outbox and domain event logs.
पूर्ण-शीर्षकम् / Full title
लेखनाग्रधर्मः: A Metrical Codification of Write-Ahead Logging (with English glosses)
English · overview and topics (minimizable)
What this post is about
Write-ahead logging records intended mutations before applying them so crash recovery can complete or roll back safely.
Topics covered
- Why log before mutate
- Intent-first ordering
- fsync durability barriers
- Group commit
- Checkpoint and truncate
- Checksums and torn writes
- Redo versus undo policy
- Replica apply order
- Outbox is not storage WAL
- Contrast with event sourcing
Sanskrit title
लेखनाग्रधर्मः = lekhana-agra-dharmaḥ “dharma of writing-ahead”.
English
Minimizable; Sanskrit-first.
परम्परा-सन्धिः / Series links
| पूर्वं / Prior | अत्र / Adds | न पुनः / Does not repeat |
|---|---|---|
| घटनास्रोतधर्मः (२५ अक्टो) | domain events | not engine WAL |
| बहिर्लेखनपटलः (२८ सितम्बे) | outbox | app message birth |
| वाचनप्रतिलिपिः (६ अक्टो) | replicas | often follow log order |
| अभिलेखतन्त्रम् (९ जुलै) | ledger | business immutability |
| इदम् | WAL durability recovery | - |
ग्राह्य-त्याज्य-विवेकः / Keep and avoid
ग्राह्यम् / Keep
१. intent before mutate: always
२. explicit fsync barriers: not cache success
३. group commit: when latency allows
४. checkpoint truncate: bound recovery
५. checksum records: reject torn tails
६. one redo/undo policy: no mixed half-work
७. replicas follow log: no side mutations
त्याज्यम् / Avoid
- treat buffered write as durable
- never truncate or checkpoint WAL
- confuse app outbox with engine WAL
अध्याय-योजना / Chapter plan
| प्रकरणम् | विषयः | छन्दः | श्लोकाः |
|---|---|---|---|
| १ | मङ्गलं बीजं च / Opening | अनुष्टुभ् | २ |
| २ | मूलतत्त्वानि / Core | अनुष्टुभ् | २ |
| ३ | मुख्यविधिः / Method | उपजाति | १ |
| ४ | रक्षा · विधिः / Guards | अनुष्टुभ् | २ |
| ५ | विवेक · सीमा / Judgment | अनुष्टुभ् | २ |
| ६ | पूर्वसन्धिः / Series links | उपजाति | १ |
| ७ | उपसंहारः / Close | अनुष्टुभ् | २ |
पारिभाषिक-कोशः / Glossary
| Modern English | संस्कृतम् | Note |
|---|---|---|
| write-ahead log | लेखनाग्रपङ्क्तिः / WAL | |
| fsync | दृढलेखनम् / fsync | |
| group commit | समूहप्रतिज्ञा | |
| checkpoint | निरीक्षणबिन्दुः | |
| redo | पुनःकरणम् | |
| undo | निरसनम् | |
| torn write | खण्डितलेखनम् | |
| checksum | योगफलरक्षा | |
| segment | खण्डः | |
| LSN / log seq | पङ्क्तिक्रमाङ्कः |
श्लोकः १ (अनुष्टुभ्)
लेखनाग्रधर्मस्तस्माद् पुनरुद्धारः ॥१॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
पूर्वं लेखनं पश्चात् स्थितिः यदि दुर्घटना ।
लेखनाग्रधर्मस्तस्माद् पुनरुद्धारः ॥१॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| पूर्वम् | before |
| लेखनम् | writing |
| पश्चात् | after |
| स्थितिः | state |
| दुर्घटना | crash |
| लेखनाग्रधर्मः | write-ahead dharma |
| पुनरुद्धारः | recovery |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| लेखनाग्रधर्मः | write-ahead log dharma |
| पुनरुद्धारः | recovery |
English sense
A write-ahead log records intended changes before applying them to the durable state so crash recovery can finish or undo work safely.
Context / topic
Topic: why WAL. Distinct from event sourcing app logs and from generic file journaling alone.
वृत्तमिति: ८-८-८-८।
श्लोकः २ (अनुष्टुभ्)
mutate-first इतिहासः नश्यति ॥२॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
intent first then mutate ।
mutate-first इतिहासः नश्यति ॥२॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| intent | intent |
| first | first |
| then | then |
| mutate | mutate |
| mutate-first | mutate first |
| इतिहासः | history |
| नश्यति | perishes |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| intent first | log before mutate |
| mutate-first | change pages then hope |
English sense
Log the intent before dirtying durable structures. Mutate-first loses the story of incomplete work on power loss.
Context / topic
Topic: ordering rule.
वृत्तमिति: ८-८-८-८।
श्लोकः ३ (अनुष्टुभ्)
buffered-only मिथ्यासिद्धिः ॥३॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
fsync barrier स्पष्टम् ।
buffered-only मिथ्यासिद्धिः ॥३॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| fsync | fsync |
| barrier | barrier |
| स्पष्टम् | clear |
| buffered-only | buffer only |
| मिथ्यासिद्धिः | false success |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| fsync barrier | durability fence |
| buffered-only | OS cache only |
English sense
Durability is a fsync or group-commit barrier not a successful write syscall to page cache.
Context / topic
Topic: durability barriers.
वृत्तमिति: ८-८-८-८।
श्लोकः ४ (अनुष्टुभ्)
प्रतिलेख fsync मन्दः ॥४॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
group commit throughput रक्षति ।
प्रतिलेख fsync मन्दः ॥४॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| group | group |
| commit | commit |
| throughput | throughput |
| रक्षति | protects |
| प्रतिलेख | per write |
| fsync | fsync |
| मन्दः | slow |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| group commit | batch fsync |
| प्रतिलेख fsync | sync every row |
English sense
Batch many logical commits behind one durability fence when latency budgets allow.
Context / topic
Topic: group commit.
वृत्तमिति: ८-८-८-८।
श्लोकः ५ (उपजाति)
पुरालॉग् ।
अनन्तपङ्क्तिः
मन्दः ॥५॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
checkpoint + truncate
पुरालॉग् ।
अनन्तपङ्क्तिः
मन्दः ॥५॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| checkpoint | checkpoint |
| truncate | truncate |
| पुरालॉग् | old log |
| अनन्तपङ्क्तिः | endless log |
| मन्दः | slow |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| checkpoint | apply and advance |
| truncate | drop old segments |
English sense
Checkpoint applied state and truncate or archive old segments. An unbounded WAL fills disks and slows recovery.
Context / topic
Topic: checkpoint and truncation.
वृत्तमिति: एकादशाक्षराः पादाः।
श्लोकः ६ (अनुष्टुभ्)
torn write मा मौन ॥६॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
checksum CRC खण्डे ।
torn write मा मौन ॥६॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| checksum | checksum |
| CRC | CRC |
| खण्डे | on segment |
| torn | torn |
| write | write |
| मा मौन | do not stay silent |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| checksum | integrity on records |
| torn write | partial sector write |
English sense
Protect log records with checksums so torn or bit-flipped tails are rejected not applied as truth.
Context / topic
Topic: integrity.
वृत्तमिति: ८-८-८-८।
श्लोकः ७ (अनुष्टुभ्)
अर्धकार्यं मा भ्रम ॥७॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
redo undo नीति स्पष्टा ।
अर्धकार्यं मा भ्रम ॥७॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| redo | redo |
| undo | undo |
| नीतिः | policy |
| स्पष्टा | clear |
| अर्धकार्यम् | half work |
| मा भ्रम | do not confuse |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| redo undo | replay vs rollback |
| अर्धकार्यम् | half-done work |
English sense
Define whether recovery redos committed intents or undoes incomplete ones. Mixed half-policies corrupt state.
Context / topic
Topic: redo/undo semantics.
वृत्तमिति: ८-८-८-८।
श्लोकः ८ (अनुष्टुभ्)
divergent mutation युद्धाय ॥८॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
replica apply same log order ।
divergent mutation युद्धाय ॥८॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| replica | replica |
| apply | apply |
| same | same |
| log | log |
| order | order |
| divergent | divergent |
| mutation | mutation |
| युद्धाय | for war |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| same log order | single writer order |
| divergent mutation | side writes |
English sense
Replicas that follow the WAL stay ordered. Independent side mutations break the log as source of truth.
Context / topic
Topic: replication from log.
वृत्तमिति: ८-८-८-८।
श्लोकः ९ (अनुष्टुभ्)
स्तराः भिन्नाः ॥९॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
app outbox != storage WAL ।
स्तराः भिन्नाः ॥९॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| app | app |
| outbox | outbox |
| storage | storage |
| WAL | WAL |
| स्तराः | layers |
| भिन्नाः | different |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| app outbox | message birth with TX |
| storage WAL | engine durability log |
English sense
Application outbox is a domain pattern. Storage WAL is an engine internal. Do not conflate the two layers.
Context / topic
Topic: outbox vs WAL distinction.
वृत्तमिति: ८-८-८-८।
श्लोकः १० (उपजाति)
लेखनाग्रः engine रक्षा ।
पटलः
जन्म रक्षति ॥१०॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
घटनास्रोतः domain इतिहासः
लेखनाग्रः engine रक्षा ।
पटलः
जन्म रक्षति ॥१०॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| घटनास्रोतः | event source |
| domain | domain |
| इतिहासः | history |
| लेखनाग्रः | write-ahead |
| engine | engine |
| रक्षा | guard |
| पटलः | outbox |
| जन्म | birth |
| रक्षति | guards |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| घटनास्रोतः | event sourcing |
| पटलः | outbox |
English sense
Event sourcing is domain history; WAL is engine durability; outbox guards message birth with the business transaction.
Context / topic
Topic: series distinctions.
सन्धिः: स्रोत डोमेन्; अग्र इञ्जिन्; पटल सन्देशजन्म।
वृत्तमिति: एकादशाक्षराः पादाः।
श्लोकः ११ (अनुष्टुभ्)
एभिर्लेखनाग्रधर्मः पुनरुद्धारसमन्वितः ॥११॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
intent barrier checkpoint integrity policy पञ्चकम् ।
एभिर्लेखनाग्रधर्मः पुनरुद्धारसमन्वितः ॥११॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| intent | intent |
| barrier | barrier |
| checkpoint | checkpoint |
| integrity | integrity |
| policy | policy |
| पञ्चकम् | five-set |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| पञ्चकम् | intent barrier checkpoint integrity policy |
English sense
Five limbs: log intent first, durable barrier, checkpoint and truncate, checksum integrity and clear redo or undo policy.
Context / topic
Topic: checklist.
वृत्तमिति: ८-८-८-८।
श्लोकः १२ (अनुष्टुभ्)
मितं पूर्वलेखनं क्रियायोग्यं तन्त्रधर्मः स उच्यते ॥१२॥
पदच्छेदः · Word-for-word · English (minimizable)
पदच्छेदः
इति लेखनाग्रधर्मसारः पुनरुद्धारसमन्वितः ।
मितं पूर्वलेखनं क्रियायोग्यं तन्त्रधर्मः स उच्यते ॥१२॥
Word-for-word
| संस्कृतपदम् | Word-for-word English |
|---|---|
| इति | thus |
| लेखनाग्रधर्मसारः | WAL essence |
| पुनरुद्धारः | recovery |
| मितम् | measured |
| पूर्वलेखनम् | prior writing |
| क्रियायोग्यम् | operable |
| तन्त्रधर्मः | system dharma |
Gloss table
| पदम् | अर्थः / sense |
|---|---|
| मितं पूर्वलेखनम् | measured write-ahead |
| तन्त्रधर्मः | platform dharma |
English sense
Closing: write the intent before the state, fence durability and keep recovery boring.
Context / topic
Topic: close.
उपसंहारन्यायः: पूर्वं लिख; पश्चात् कुरु; fsyncं स्मर।
वृत्तमिति: ८-८-८-८।
श्लोकसूची / Verse index
१. Why WAL
२. Intent first
३. fsync
४. Group commit
५. Checkpoint
६. Checksum
७. Redo/undo
८. Replicas
९. vs outbox
१०. vs ES
११. Five limbs
१२. Close
सन्दर्भाः / References
- Prior: event sourcing 2026-10-25; outbox 2026-09-28; read replicas 2026-10-06.
- Domain: storage engine write-ahead logging.
- English minimizable; Sanskrit-first.
- Style: no em dash; no Oxford comma in English clauses.