From 0e938d09f7d6f0aa1cf471a4d0fd52dc7dad25ef Mon Sep 17 00:00:00 2001 From: yangxin Date: Mon, 18 Nov 2024 14:56:46 +0800 Subject: [PATCH] Skip apply ioworkers when seek(0, io.SeekCurrent) --- br/pkg/lightning/mydump/reader.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/br/pkg/lightning/mydump/reader.go b/br/pkg/lightning/mydump/reader.go index 39cf5ca224c58..1a25cd31b58f0 100644 --- a/br/pkg/lightning/mydump/reader.go +++ b/br/pkg/lightning/mydump/reader.go @@ -187,7 +187,8 @@ func (pr PooledReader) Read(p []byte) (n int, err error) { // Seek implements io.Seeker func (pr PooledReader) Seek(offset int64, whence int) (int64, error) { - if pr.ioWorkers != nil { + // Seek(0, io.SeekCurrent) is used to get the current offset, which will not cause any Disk I/O. + if pr.ioWorkers != nil && !(offset == 0 && whence == io.SeekCurrent) { w := pr.ioWorkers.Apply() defer pr.ioWorkers.Recycle(w) }