Skip to content

Commit

Permalink
Lightning: Skip apply ioworkers when seek(0, io.SeekCurrent) (#57454) (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Feb 17, 2025
1 parent 19843ce commit 017dd17
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions br/pkg/lightning/mydump/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,11 @@ func (pr PooledReader) Read(p []byte) (n int, err error) {

// Seek implements io.Seeker
func (pr PooledReader) Seek(offset int64, whence int) (int64, error) {
w := pr.ioWorkers.Apply()
defer pr.ioWorkers.Recycle(w)
// 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)
}
return pr.reader.Seek(offset, whence)
}

Expand Down

0 comments on commit 017dd17

Please sign in to comment.