feat(wal): implement WAL writer with group commit and recovery batch replay

- wal/commit_queue.go: bounded buffered channel for write requests
- wal/writer.go: single-goroutine main loop implementing 11-step write flow
  with group commit, sequence allocation, MemTable publish/abort, write-stopped
- wal/recovery.go: BatchReplayer interface, ReplayBatch, ReplaySegmentFile,
  RecoverFromSegments with fragment reassembly and tail corruption handling
- Comprehensive tests for all modules, all pass with -race
This commit is contained in:
dailz
2026-06-12 13:57:31 +08:00
parent 08960a9bcf
commit fe2d4fc5f0
7 changed files with 971 additions and 4 deletions
+28 -2
View File
@@ -8,7 +8,7 @@
"plan_name": "phase1-wal",
"status": "active",
"started_at": "2026-06-12T05:09:32.588Z",
"updated_at": "2026-06-12T05:49:50.501Z",
"updated_at": "2026-06-12T05:57:16.412Z",
"session_ids": [
"opencode:ses_145c3bae9ffeTB2zbsTym0Cev8"
],
@@ -94,6 +94,19 @@
"status": "completed",
"ended_at": "2026-06-12T05:49:50.501Z",
"elapsed_ms": 106010
},
"todo:13": {
"task_key": "todo:13",
"task_label": "13",
"task_title": "Commit queue + WAL writer main loop",
"session_id": "opencode:ses_1459dbbd5ffewqrKSfu5f6t38q",
"agent": "Sisyphus-Junior",
"category": "deep",
"updated_at": "2026-06-12T05:57:16.412Z",
"started_at": "2026-06-12T05:56:53.263Z",
"status": "completed",
"ended_at": "2026-06-12T05:57:16.412Z",
"elapsed_ms": 23149
}
}
}
@@ -101,7 +114,7 @@
"active_plan": "/home/dailz/workspace/src/go-kv/.omo/plans/phase1-wal.md",
"started_at": "2026-06-12T05:09:32.588Z",
"status": "active",
"updated_at": "2026-06-12T05:49:50.501Z",
"updated_at": "2026-06-12T05:57:16.412Z",
"session_ids": [
"opencode:ses_145c3bae9ffeTB2zbsTym0Cev8"
],
@@ -187,6 +200,19 @@
"status": "completed",
"ended_at": "2026-06-12T05:49:50.501Z",
"elapsed_ms": 106010
},
"todo:13": {
"task_key": "todo:13",
"task_label": "13",
"task_title": "Commit queue + WAL writer main loop",
"session_id": "opencode:ses_1459dbbd5ffewqrKSfu5f6t38q",
"agent": "Sisyphus-Junior",
"category": "deep",
"updated_at": "2026-06-12T05:57:16.412Z",
"started_at": "2026-06-12T05:56:53.263Z",
"status": "completed",
"ended_at": "2026-06-12T05:57:16.412Z",
"elapsed_ms": 23149
}
},
"agent": "atlas"
+2 -2
View File
@@ -1009,7 +1009,7 @@ Max Concurrent: 6 (Wave 1b)
**Commit**: YES (with Task 13)
- [ ] 13. Commit queue + WAL writer main loop
- [x] 13. Commit queue + WAL writer main loop
**What to do**:
- 创建 `wal/commit_queue.go``CommitQueue` — 写请求队列
@@ -1233,7 +1233,7 @@ Max Concurrent: 6 (Wave 1b)
**Commit**: YES (with Tasks 16, 17)
- [ ] 16. WAL recovery: fragment collector + batch replay
- [x] 16. WAL recovery: fragment collector + batch replay
**What to do**:
- 创建 `wal/recovery.go`:恢复核心逻辑