From 3f65f051a6eaedb8669baa6f5afa728dfd398a5f Mon Sep 17 00:00:00 2001 From: Davies Liu Date: Wed, 17 Apr 2024 16:52:18 +0800 Subject: [PATCH] Revert "Prepare slice id eagerly to have a stable and predictable write buffer usage" (#4720) --- pkg/chunk/cached_store.go | 3 --- pkg/vfs/writer.go | 5 ++--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/chunk/cached_store.go b/pkg/chunk/cached_store.go index 19d3e7013254..5c49f81b9650 100644 --- a/pkg/chunk/cached_store.go +++ b/pkg/chunk/cached_store.go @@ -412,9 +412,6 @@ func (s *wSlice) upload(indx int) { blen := s.blockSize(indx) key := s.key(indx) pages := s.pages[indx] - if pages == nil { - panic(fmt.Sprintf("block #%d is nil, concurrent upload?", indx)) - } s.pages[indx] = nil s.pendings++ diff --git a/pkg/vfs/writer.go b/pkg/vfs/writer.go index 1f6a381150cc..692e4ba39df6 100644 --- a/pkg/vfs/writer.go +++ b/pkg/vfs/writer.go @@ -135,9 +135,6 @@ func (s *sliceWriter) write(ctx meta.Context, off uint32, data []uint8) syscall. s.slen = off + uint32(len(data)) } s.lastMod = time.Now() - if s.id == 0 { - go s.prepareID(ctx, false) - } if s.slen == meta.ChunkSize { s.freezed = true go s.flushData() @@ -148,6 +145,8 @@ func (s *sliceWriter) write(ctx meta.Context, off uint32, data []uint8) syscall. logger.Warnf("write: chunk: %d off: %d %s", s.id, off, err) return syscall.EIO } + } else if int(off) <= f.w.blockSize { + go s.prepareID(ctx, false) } } return 0