Skip to content

making append log entries atomic in nature - #26

Merged
codecasualty merged 1 commit into
mainfrom
feature/gateway-fixes
Sep 22, 2026
Merged

codecasualty merged 1 commit into
mainfrom
feature/gateway-fixes

Conversation

@codecasualty

Copy link
Copy Markdown
Owner

What this does

Three main changes:

1. Fixed follower crash after failover

  • A restarted node could crash because commitIndex temporarily pointed beyond the in-memory log while AppendEntries was updating it.
  • Fixed by writing to the WAL first, then atomically truncating and appending to the in-memory log under one lock.
  • Added WAL TRUNCATE records and prevented failed WAL writes from leaving a partially modified log.
  • Verified with unit tests, integration/durability tests, and two live 3-node chaos runs.

2. Disabled benchmark logging by default

  • METRICS logging was accidentally enabled at INFO, generating heavy disk I/O and competing with WAL fsyncs.
  • Now disabled by default; enable it explicitly for benchmarks.

3. Notes

  • Follower still truncates beyond prevLogIndex even without a conflict; safe but inefficient.
  • The apply loop should additionally enforce lastApplied <= log.lastIndex().

@codecasualty
codecasualty merged commit c37045f into main Sep 22, 2026
1 check passed
@codecasualty
codecasualty deleted the feature/gateway-fixes branch September 28, 2026 07:20
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.

1 participant