From 0e3efb6ea8b96f0adee424391fd1c416d5ec35dd Mon Sep 17 00:00:00 2001 From: Leon Yang Date: Tue, 19 Nov 2024 16:15:20 +0800 Subject: [PATCH] Lightning: Skip apply ioworkers when seek(0, io.SeekCurrent) (#57454) close pingcap/tidb#57413 --- pkg/lightning/mydump/reader.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/lightning/mydump/reader.go b/pkg/lightning/mydump/reader.go index b5e21583105e3..c70328c6d8d9f 100644 --- a/pkg/lightning/mydump/reader.go +++ b/pkg/lightning/mydump/reader.go @@ -189,7 +189,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) }