After every restart your book is subtly wrong — a few price levels stay stale until the next full refresh. The code requests the snapshot, applies it, then subscribes to increments. Where is the bug?
- The snapshot is stale and the venue should be asked for a fresher one. A snapshot is a point in the sequence; it is fine as long as you replay from that point.
- The receive buffer is too small. That would show as gap counters and UdpRcvbufErrors, not as a consistent post-restart pattern.
- The join order: everything published between the snapshot and the subscription is lost. Subscribe and buffer increments first, then apply the snapshot, then replay buffered increments from the snapshot's sequence. The gap between snapshot and subscription is exactly the missing data.
- Increments must be applied newest-first. Increments are strictly in sequence order.
The join order is wrong: subscribe to increments first, then apply the snapshot, then replay what you buffered.
This is the classic market-data ordering bug and it is invisible in testing on a quiet instrument. The fix is a state machine: BUFFERING → SNAPSHOT_APPLIED → REPLAYING → LIVE, with the book untrusted until it reaches LIVE.
Blaming a stale snapshot or the buffer. A snapshot is just a point in the sequence; the hole is everything published between the snapshot and the subscription.