You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(code/engine): Buffer consensus messages during startup and recovery (#860)
* feat(engine): Buffer consensus messages during startup and recovery
This commit introduces message buffering for the consensus engine during startup and
recovery phases. This is an important improvement to handle messages that arrive
before the consensus engine is fully started or while it is recovering state via the WAL.
- Add a `VecDeque` buffer to store messages that arrive during `Unstarted`/`Recovering` phases
- Implement a message filtering function to determine which messages should be buffered
- Add processing of buffered messages once consensus starts
- Set a maximum buffer size of 1024 messages to prevent unbounded memory growth
Messages that should be buffered include votes, proposals, and proposal parts.
Control messages like `StartHeight`, `TimeoutElapsed`, and network
connection events are processed immediately.
The buffered messages are replayed in order once:
1. The WAL has been checked and replayed
2. The consensus engine transitions to the `Running` phase
The buffer size is capped at 1024 messages to prevent memory exhaustion attacks.
Messages beyond this limit are dropped with a warning log.
* Buffer elapsed timeouts as well
This does not really matter since no timeout can actually expire while we are replaying the WAL,
but it is less misleading that way
0 commit comments