From 9a00c17555e00e6c3b05c93add9042a3293cfb19 Mon Sep 17 00:00:00 2001 From: chrislu Date: Tue, 28 Dec 2021 16:30:33 -0800 Subject: [PATCH] reader: avoid wrong pattern detection due to lock waiting --- weed/filer/reader_at.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go index b73526761..670de382c 100644 --- a/weed/filer/reader_at.go +++ b/weed/filer/reader_at.go @@ -105,11 +105,11 @@ func (c *ChunkReadAt) Close() error { func (c *ChunkReadAt) ReadAt(p []byte, offset int64) (n int, err error) { + c.readerPattern.MonitorReadAt(offset, len(p)) + c.readerLock.Lock() defer c.readerLock.Unlock() - c.readerPattern.MonitorReadAt(offset, len(p)) - // glog.V(4).Infof("ReadAt [%d,%d) of total file size %d bytes %d chunk views", offset, offset+int64(len(p)), c.fileSize, len(c.chunkViews)) return c.doReadAt(p, offset) }