From a58b7874ef04ada1c53be546404223c3f23745c2 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Mon, 23 Nov 2020 18:51:59 -0800 Subject: [PATCH] Temporary workaround for msgp skipping (#10960) Due to https://github.com/philhofer/fwd/issues/20 when skipping a metadata entry that is >2048 bytes and the buffer is full (2048 bytes) the skip will fail with `io.ErrNoProgress`. Enlarge the buffer so we temporarily make this much more unlikely. If it still happens we will have to rewrite the skips to reads. Fixes #10959 --- cmd/metacache-stream.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/metacache-stream.go b/cmd/metacache-stream.go index b6a2d1b3c..3c8515c5a 100644 --- a/cmd/metacache-stream.go +++ b/cmd/metacache-stream.go @@ -247,7 +247,9 @@ type metacacheReader struct { func newMetacacheReader(r io.Reader) (*metacacheReader, error) { dec := s2DecPool.Get().(*s2.Reader) dec.Reset(r) - mr := msgp.NewReader(dec) + // TODO: Go back to default size when this fix is available: + // https://github.com/philhofer/fwd/issues/20 + mr := msgp.NewReaderSize(dec, 64<<10) m := metacacheReader{ mr: mr, closer: func() { @@ -429,8 +431,8 @@ func (r *metacacheReader) forwardTo(s string) error { } if string(tmp) >= s { r.current.name = string(tmp) - r.current.metadata, err = r.mr.ReadBytes(nil) - return err + r.current.metadata, r.err = r.mr.ReadBytes(nil) + return r.err } // Skip metadata err = r.mr.Skip()