Commit graph

16 commits

Author SHA1 Message Date
Trevon
8000226a4c
fix(wal): encode the entry header field by field, never via padding (#274)
* test(wal): pin v1 entry encoding to a Clang-written fixture

store_block_entry_clang_v1.bin is one StoreBlock entry serialized by the
current wal_entry.cpp built with Clang 21, which zero-fills the 4 bytes of
trailing Header padding. The new cases decode and verify it, re-encode the
same logical entry and require identical bytes, and round-trip fresh
entries through serialize/deserialize/verifyChecksum.

GCC 16 leaves that padding uninitialized in stableHeaderBytes(), so these
cases fail there.

Signed-off-by: trvon <me@trevon.dev>

* fix(wal): encode entry header field by field, never via padding

stableHeaderBytes() built the checksummed header with `Header stable{}`
plus member assignments and then memcpy'd sizeof(Header) bytes. That is
aggregate initialization, so the 4 bytes of trailing padding (offsets
44..47) are not guaranteed to be zero. Clang 21 memsets the object first;
GCC 16 at -O0 stores only the members, so stack garbage reached both the
serialized entry and the CRC, and verifyChecksum() failed on GCC builds.

Encode and decode the header field by field into a zero-filled 48-byte
array at the existing offsets, with static_asserts pinning every offset
and size. The checksum is CRC32 over that canonical encoding plus the
payload, which is exactly what Clang builds have always written, so their
WAL files verify unchanged. deserialize() also accepts an entry whose CRC
covers nonzero padding as stored on disk (written by earlier GCC builds)
and normalizes its in-memory checksum. WALFile and WALManager recovery
read headers through the new WALEntry::decodeHeader().

TransactionData (uint64 + uint32) has 4 bytes of trailing padding and was
copied whole into the payload, relying on the same unguaranteed zeroing
(GCC 16 and Clang 21 happen to zero it today); it is now encoded field by
field too. The remaining payload structs are padding-free, which
appendObjectBytes/readObject now enforce with
has_unique_object_representations_v.

Signed-off-by: trvon <me@trevon.dev>

---------

Signed-off-by: trvon <me@trevon.dev>
2026-10-08 14:30:25 -06:00
trvon
be95561c1e
fix(wal): keep WAL metrics noexcept and race-free
getStats() is noexcept but calls a WALManager query that iterates the
WAL directory, so an inaccessible directory terminated the daemon
instead of degrading to zeroed metrics. Catch and report zeros.

WALManager::getStats() also read lastSync/lastRotation after releasing
stateMutex while the sync and rotation paths write them under it. Read
them inside the same critical section.

Signed-off-by: trvon <me@trevon.dev>
2026-09-19 12:45:34 -06:00
trvon
a636204f42
fix(wal): preserve damaged zero-prefix segments
Only prune a nonempty segment after every byte is proven zero. A zero header alone is not evidence that recovery data is absent. Scan with bounded memory and preserve the file on read failure.

Signed-off-by: trvon <me@trevon.dev>
2026-09-10 16:26:08 -06:00
trvon
9dc37e0af9
fix(wal): require an explicit WAL directory and prune empty segments
WALManager::Config defaulted walDirectory to "./wal", so any manager built
from a default config wrote segments into the process working directory.
The repo root had accumulated 43,577 such files (42,499 zero-byte, 1,078
zero-filled 1 MiB mmap preallocations from killed writers; 1.1 GB, no
entries). The daemon already passes <dataDir>/wal explicitly.

- walDirectory has no default; initialize() returns InvalidArgument when
  it is empty. The default constructor is removed (it had no callers).
- initialize() still derives the sequence from every segment name, then
  deletes plain segments that never received an entry: zero bytes, or a
  zero magic word at offset 0 (a preallocation left by an unclean exit).
  Compressed segments and anything with real bytes are untouched.

Tests: unconfigured directory is rejected; 50 empty + 1 preallocated
segments are pruned, a non-empty one survives, and the sequence still
advances past the pruned names.

Signed-off-by: trvon <me@trevon.dev>
2026-09-10 16:24:42 -06:00
trvon
5d967b9708
feat(metrics): surface WAL data-system optics in daemon status
WalMetricsProvider::getStats() was wired (attachWalManager) but never
consumed anywhere: WAL active/pending/total entries, bytes, and log-file
count were invisible to operators. Close the optics gap:

- MetricsSnapshot: add walActiveTransactions/PendingEntries/TotalEntries/
  TotalBytes/LogFileCount (detailed snapshot only).
- DaemonMetrics::enrichDetailedSnapshot: populate from
  ServiceManager::getWalMetricsProvider() (cheap atomic reads).
- request_dispatcher_status: emit wal_* requestCounts on detailed status.
- metric_keys.h: kWAL* keys (wal_active_transactions, ...).
- status_command --json: render a 'wal' object when counters are nonzero.
- tests: WalMetricsProvider pass-through unit tests (zeros without a
  manager; forwards WALManager stats; reset on null manager).

Validated: build/debug suite (ConfigResolver 42 cases, metrics core/status,
new WAL provider tests) plus brick (0 new cycles on touched files) and fold
(0 findings on added lines).
2026-09-01 13:55:44 -06:00
trvon
014e12c975
fix: testing improvements and bug fixes in daemon logic for lifecycle management 2026-02-17 15:55:29 -05:00
trvon
448f5e47b4
fix: fixing repairmanager logic, windows build issues, linting, resource scaling 2026-02-07 22:07:56 -05:00
trvon
b071112836
feat: test coverage improvements. Scaling bug addresses 2026-02-04 20:20:18 -05:00
trvon
ce3d9d526b
PBI-043: Integrate tree_diff benchmarks into nightly CI (Task 043-16)
- Add tree_diff benchmark run step to nightly workflow
- Add regression check against baseline thresholds
- Create baseline file with AC#7 metrics (tree_overhead ≤15%)
- Update artifact uploads to include tree_diff results

Validates:
- AC #2: Diff latency < 750ms p95 (10k entries)
- AC #7: Tree storage overhead ≤ 15%
- Task 043-07: Multi-snapshot dedup metrics

Progress: Task 043-16 in_progress
2025-10-07 10:52:11 -04:00
Trevon
9f4c3b734c
test framework stabilizations and bug fixes 2025-09-23 22:07:22 -04:00
Trevon
43699f99a3
v0.7.0-prerelease 2025-09-20 22:55:34 -04:00
Trevon
956c43b80b
v0.6.12 experiemental 2025-09-11 11:28:42 -04:00
Trevon
abdbd68e06
build system improvements, clang-tidy integration for warnings equals errors (need to continue). POSIX socket legacy code removal 2025-09-03 13:22:30 -04:00
Trevon
3defa60de5
v0.3.3 clang-format now in use 2025-08-15 15:51:18 -04:00
Trevon
a84300555a
v0.3.2 2025-08-15 04:30:05 -04:00
Trevon
917aecf514
yams 2025-08-10 23:41:49 -04:00