Copilot commented on code in PR #11678:
URL: https://github.com/apache/ozone/pull/11678#discussion_r4560266453
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/KeyValueStreamDataChannel.java:
##########
@@ -171,6 +178,34 @@ public void drainBuffers() throws IOException {
}
}
+ /**
+ * Write the data in {@link #buffers} to the channel until the block file
has at least the given length.
+ * It must be called before committing a PutBlock with this block length.
+ * Unlike {@link #drainBuffers()}, it does not write all the data:
+ * the end of the stream may be the PutBlock request, which must not be
written to the block file.
+ * Since the client sends the PutBlock request in separate packets after the
data,
+ * whole buffers can be written as long as the block file is shorter than
the given length.
+ */
+ synchronized void drainBuffers(long length) throws IOException {
+ if (closed.get()) {
+ // close() has written the data, or cleanUp() has dropped it.
+ return;
Review Comment:
`close()` sets `closed` before acquiring the buffer monitor, so this check
can skip draining while the tail is still only in memory. Since the client
submits the Raft PutBlock without waiting for stream close, that interleaving
can commit a block length ahead of its data. Make the close-state transition
and tail write atomic with draining, keep the PutBlock callback outside the
monitor, and add a deterministic close-versus-drain regression test.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]