feat(ha-single-leader-role): WAL_NOOP entry type — enum + apply no-op + RETAIN classify (task 1.2)

This commit is contained in:
Rongsong Shen 2026-06-13 07:45:21 +00:00
parent 6df1283f1a
commit e6abd7c8af
3 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;