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
This commit is contained in:
Klaus Post 2020-11-23 18:51:59 -08:00 committed by GitHub
parent 6990de9c94
commit a58b7874ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -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()