From e6abd7c8af0fb745f49bbbe10fe4c98d6512e1ae Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Sat, 13 Jun 2026 07:45:21 +0000 Subject: [PATCH] =?UTF-8?q?feat(ha-single-leader-role):=20WAL=5FNOOP=20ent?= =?UTF-8?q?ry=20type=20=E2=80=94=20enum=20+=20apply=20no-op=20+=20RETAIN?= =?UTF-8?q?=20classify=20(task=201.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .kiro/specs/ha-single-leader-role/tasks.md | 2 +- src/controller/persist.c | 11 +++++++++++ src/include/wal_types.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.kiro/specs/ha-single-leader-role/tasks.md b/.kiro/specs/ha-single-leader-role/tasks.md index 69fc5deb..2717f970 100644 --- a/.kiro/specs/ha-single-leader-role/tasks.md +++ b/.kiro/specs/ha-single-leader-role/tasks.md @@ -11,7 +11,7 @@ - Observable completion: build succeeds with the new test file; all new cases FAIL (red) — `WAL_NOOP` does not exist yet - _Requirements: 2.1_ -- [ ] 1.2 Implement WAL_NOOP to green +- [x] 1.2 Implement WAL_NOOP to green - Add `WAL_NOOP = 40` to `wal_entry_type` (src/include/wal_types.h:44-58) with comment: internal, empty payload, replay no-op, appended only at promotion; value stays below `WAL_ENTRY_TYPE_MAX` (100, src/include/config.h:80) so standbys LSN-advance and ACK it via the existing common path - Add explicit `case WAL_NOOP: break;` to `apply_wal_entry`'s type switch (persist.c:728-765 anchor); add the `WAL_NOOP → WAL_MODE_RETAIN` row to `wal_classify` (the row barrier-rollout pre-declared) - Observable completion: all task 1.1 tests PASS; barrier-rollout's classification totality test still PASSES diff --git a/src/controller/persist.c b/src/controller/persist.c index b80c981b..c0cbfc90 100644 --- a/src/controller/persist.c +++ b/src/controller/persist.c @@ -764,6 +764,12 @@ int apply_wal_entry(persist_t* p, const wal_entry_hdr_t* hdr, const void* payloa } break; + case WAL_NOOP: + /* Internal promotion no-op: empty payload, no entity restore, no + * hooks. The common-path current_lsn advance (above) is its only + * effect — recognised explicitly here rather than via default. */ + break; + default: break; } @@ -1160,6 +1166,11 @@ wal_commit_mode_t wal_classify(uint32_t wal_type, int detail) * realized by the handler barrier in do_jobcontrol_op * (research.md §2 call-site verification). */ return WAL_MODE_RETAIN; + case WAL_NOOP: + /* internal promotion no-op — replicated like any committed entry, + * retained until committed (ha-commit-barrier-rollout pre-declared + * row: promotion | internal | RETAIN; guard forces classification) */ + return WAL_MODE_RETAIN; case WAL_CHECKPOINT: /* local segment marker — never replicated, by design */ return WAL_MODE_LOCAL; diff --git a/src/include/wal_types.h b/src/include/wal_types.h index c4d89e9b..8b17c7c4 100644 --- a/src/include/wal_types.h +++ b/src/include/wal_types.h @@ -54,5 +54,6 @@ typedef enum { WAL_JOB_PREASON = 10, WAL_QUEUE_CTRL = 20, WAL_WORKER_CTRL = 30, + WAL_NOOP = 40, /* Internal: empty payload, replay no-op; appended only at promotion */ WAL_CHECKPOINT = 100, /* Local WAL marker only — never replicated */ } wal_entry_type;