From bba101bbab65ff2ddcfcb8621d01ea2bc6d47075 Mon Sep 17 00:00:00 2001 From: lakshit verma Date: Fri, 21 Aug 2026 21:38:52 +0530 Subject: [PATCH] tailer: account for every fetched entry and log skips fetchRange counted an entry as consumed before attempting to decode it, so undecodable entries were skipped permanently with no record, and the position could overshoot the requested range if a log served more entries than asked. The position now advances by exactly the number of received entries (clamped to the range) and skips are logged with their index window. --- internal/tailer/tailer.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/tailer/tailer.go b/internal/tailer/tailer.go index 0fafde0..187ed94 100644 --- a/internal/tailer/tailer.go +++ b/internal/tailer/tailer.go @@ -156,11 +156,11 @@ func (t *Tailer) fetchRange(ctx context.Context, client *rfc6962.Client, logID s if len(entries) == 0 { return total, nil } - decoded := int64(0) + skipped := int64(0) for _, e := range entries { leaf, err := rfc6962.DecodeLeafEntry(e) - decoded++ if err != nil { + skipped++ continue } fs := leaf.Timestamp @@ -170,6 +170,7 @@ func (t *Tailer) fetchRange(ctx context.Context, client *rfc6962.Client, logID s } } if fs <= 0 { + skipped++ continue } for _, name := range leaf.Names { @@ -182,8 +183,15 @@ func (t *Tailer) fetchRange(ctx context.Context, client *rfc6962.Client, logID s } } } - total += decoded - pos += decoded + if skipped > 0 { + log.Printf("tail %s: skipped %d undecodable entries in [%d,%d]", client.ShortID(), skipped, pos, end) + } + n := int64(len(entries)) + if pos+n > to { + n = to - pos + } + total += n + pos += n } return total, nil }