TanYuxin-tyx commented on code in PR #22652:
URL: https://github.com/apache/flink/pull/22652#discussion_r1212694450
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/storage/TieredStorageProducerClient.java:
##########
@@ -100,11 +128,13 @@ public void close() {
*/
private void writeAccumulatedBuffers(
TieredStorageSubpartitionId subpartitionId, List<Buffer>
accumulatedBuffers) {
+ Queue<Buffer> buffers = new ArrayDeque<>(accumulatedBuffers);
try {
- for (Buffer finishedBuffer : accumulatedBuffers) {
- writeAccumulatedBuffer(subpartitionId, finishedBuffer);
+ while (!buffers.isEmpty()) {
+ writeAccumulatedBuffer(subpartitionId, buffers.poll());
}
} catch (IOException e) {
+ buffers.forEach(Buffer::recycleBuffer);
ExceptionUtils.rethrow(e);
}
Review Comment:
1. Replaced it with `iterator`.
2. The exception will be thrown only when choosing a tier. So we should
recycle the writing buffer in the `writeAccumulatedBuffers`.
In `writeAccumulatedBuffer`, the `write` will not throw an exception
currently.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]