Skip to content

feat: Implement Write-Ahead Log (WAL) pattern (#3576) - #3582

Open
devikae wants to merge 2 commits into
iluwatar:masterfrom
devikae:feat/write-ahead-log-pattern
Open

feat: Implement Write-Ahead Log (WAL) pattern (#3576)#3582
devikae wants to merge 2 commits into
iluwatar:masterfrom
devikae:feat/write-ahead-log-pattern

Conversation

@devikae

@devikae devikae commented Aug 20, 2026

Copy link
Copy Markdown

Fixes #3576

Pattern Name

Write-Ahead Log (WAL) Pattern

Intent

The Write-Ahead Log (WAL) pattern ensures data durability and system recoverability in database engines, distributed consensus protocols, and transactional systems by writing all state mutations sequentially to an append-only log file on stable storage before modifying in-memory storage structures.

Summary of Changes

  • Added new standalone module write-ahead-log to parent pom.xml.
  • Implemented core classes: WriteAheadLog, DatabaseStore, LogEntry, OperationType, and App.
  • Added unit tests (LogEntryTest, WriteAheadLogTest, DatabaseStoreTest, AppTest) with 100% pass rate.
  • Provided complete README.md with intent, Mermaid UML class diagram, code snippets, and real-world use cases.
  • Ensured formatting compliance via Spotless (spotless:check).

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown

PR Summary

Introduced a new standalone module write-ahead-log implementing the Write-Ahead Log (WAL) pattern. Adds core classes (WriteAheadLog, DatabaseStore, LogEntry, OperationType, App), along with unit tests and a comprehensive README. Updated root Maven POM to declare the new module. All tests pass successfully.

Changes

File Summary
pom.xml Modified root POM to declare new write-ahead-log module, enabling Maven to build the WAL pattern alongside existing modules.
write-ahead-log/README.md Added comprehensive README with pattern intent, class diagram, practical examples, and usage guidance.
write-ahead-log/pom.xml Introduced write-ahead-log module with dependencies (slf4j, logback, lombok, JUnit 5 engine, Mockito) and build configuration including main-class for App.
write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/App.java Implemented App demonstrating WAL usage: initialization, data operations, crash simulation, and recovery.
write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/DatabaseStore.java Implemented DatabaseStore coordinating WriteAheadLog with an in-memory memTable and supporting put, delete, get, checkpoint, crash simulation, and recovery.
write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/LogEntry.java Implemented LogEntry with fields sequenceNumber, type, key, value, and serialization/deserialization to/from pipe-delimited strings.
write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/OperationType.java Defined OperationType enum with SET, DELETE, and CHECKPOINT values.
write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/WriteAheadLog.java Implemented WriteAheadLog to append, read all, and clear WAL entries with sequential numbering and persistence.
write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/AppTest.java Added test ensuring App.main executes without exceptions.
write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/DatabaseStoreTest.java Tests for put/get, delete, crash simulation, checkpoint, and recovery behavior.
write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/LogEntryTest.java Tests for LogEntry serialization, deserialization, validation, and equality.
write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/WriteAheadLogTest.java Tests for append/readAll, sequence resumption on reopen, clear and IO handling.

autogenerated by presubmit.ai

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 058fc40: feat: Implement Write-Ahead Log (WAL) pattern (#3576)
Files Processed (12)
  • pom.xml (1 hunk)
  • write-ahead-log/README.md (1 hunk)
  • write-ahead-log/pom.xml (1 hunk)
  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/App.java (1 hunk)
  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/DatabaseStore.java (1 hunk)
  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/LogEntry.java (1 hunk)
  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/OperationType.java (1 hunk)
  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/WriteAheadLog.java (1 hunk)
  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/AppTest.java (1 hunk)
  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/DatabaseStoreTest.java (1 hunk)
  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/LogEntryTest.java (1 hunk)
  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/WriteAheadLogTest.java (1 hunk)
Actionable Comments (5)
  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/App.java [52-55]

    bug: "Incorrect logger usage (undefined LOGGER)"

  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/WriteAheadLog.java [91-91]

    bug: "Logger usage mismatch in WAL append"

  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/WriteAheadLog.java [114-114]

    bug: "Logger usage mismatch in WAL read error"

  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/DatabaseStore.java [65-66]

    bug: "Logger usage in put method"

  • write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/DatabaseStore.java [78-78]

    bug: "Logger usage in delete method"

Skipped Comments (0)

Comment thread write-ahead-log/src/main/java/com/iluwatar/writeaheadlog/App.java
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.96552% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.69%. Comparing base (22a3412) to head (e604256).

Files with missing lines Patch % Lines
.../src/main/java/com/iluwatar/writeaheadlog/App.java 85.71% 3 Missing and 1 partial ⚠️
...java/com/iluwatar/writeaheadlog/WriteAheadLog.java 92.30% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3582      +/-   ##
============================================
+ Coverage     83.54%   83.69%   +0.14%     
- Complexity     4212     4248      +36     
============================================
  Files          1107     1112       +5     
  Lines         14907    15023     +116     
  Branches        704      717      +13     
============================================
+ Hits          12454    12573     +119     
+ Misses         2160     2158       -2     
+ Partials        293      292       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
  • e604256: test: Add exception handling tests and verify coverage
Files Processed (1)
  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/WriteAheadLogTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (5)
  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/WriteAheadLogTest.java [67-82]

    enhancement: "Verify durability semantics across restarts."

  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/WriteAheadLogTest.java [85-93]

    possible issue: "Assume durability on append for sequence numbers after reopen."

  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/WriteAheadLogTest.java [109-118]

    enhancement: "Stabilize IO-error test with temp directory facilities."

  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/WriteAheadLogTest.java [121-133]

    enhancement: "IO error coverage for clear() edge cases."

  • write-ahead-log/src/test/java/com/iluwatar/writeaheadlog/WriteAheadLogTest.java [67-93]

    possible issue: "Restart resume relies on flush semantics."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add Write-Ahead Log (WAL) Design Pattern

1 participant