mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 15:53:28 +03:00
fix: restore safe erasure read buffer pooling
Wire the preallocated pooled shard slices into parallelReader instead of discarding them and allocating a buffer for each disk. Keep readerToBuf as a permutation while preferred readers are reordered. The former assignments could duplicate a buffer slot after multiple swaps, causing concurrent writes and a possible decode stall. Add pool aliasing and mapping regression coverage. Co-authored-by: ChatGPT <noreply@openai.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,7 @@ func newParallelReader(readers []io.ReaderAt, e Erasure, offset, totalLength int
|
||||
offset: (offset / e.blockSize) * e.ShardSize(),
|
||||
shardSize: e.ShardSize(),
|
||||
shardFileSize: e.ShardFileSize(totalLength),
|
||||
buf: make([][]byte, len(readers)),
|
||||
buf: bufs,
|
||||
readerToBuf: r2b,
|
||||
stashBuffer: b,
|
||||
}
|
||||
@@ -106,8 +106,7 @@ func (p *parallelReader) preferReaders(prefer []bool) {
|
||||
// Move reader with index i to index next.
|
||||
// Do this by swapping next and i
|
||||
p.readers[next], p.readers[i] = p.readers[i], p.readers[next]
|
||||
p.readerToBuf[next] = i
|
||||
p.readerToBuf[i] = next
|
||||
p.readerToBuf[next], p.readerToBuf[i] = p.readerToBuf[i], p.readerToBuf[next]
|
||||
next++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user