RajaVinoth96 commented on code in PR #20263:
URL: https://github.com/apache/pinot/pull/20263#discussion_r4732353439
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/BaseChunkForwardIndexWriter.java:
##########
@@ -98,16 +99,20 @@ protected BaseChunkForwardIndexWriter(File file,
ChunkCompressionType compressio
public void close()
throws IOException {
- // Write the chunk if it is non-empty.
- if (_chunkBuffer.position() > 0) {
- writeChunk();
+ try {
+ // Write the chunk if it is non-empty.
+ if (_chunkBuffer.position() > 0) {
+ writeChunk();
+ }
+
+ // Write the header and make the file durable. Only sync on success; a
failed write is not worth syncing.
+ _header.flip();
+ _dataFile.write(_header, 0);
+ _dataFile.force(true);
Review Comment:
Thanks, makes sense. Done in c2e1916: the individual writer syncs are
removed (including the per-resize msync in `BitmapInvertedIndexWriter`), and
the build now does a single sync on the final index at the end: the final files
plus the directories, so it covers both v1 and v3. Callers with throwaway
output (minion tasks, batch ingestion) skip it via
`SegmentGeneratorConfig.setDurableOutput(false)`.
##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/memory/PinotDataBuffer.java:
##########
@@ -318,6 +318,40 @@ public static List<String> getBufferInfo() {
return bufferInfo;
}
+ /// Flushes each buffer's dirty pages to durable storage before closing it.
Without this, a write can sit
+ /// unconfirmed in the page cache, and a fault before the OS's own lazy
writeback runs can leave bad bytes on
+ /// disk with no error. Every buffer is attempted even if an earlier one
fails to flush or close. A buffer
+ /// always attempts release after a flush failure, and later buffers are
still attempted.
+ ///
+ /// @param buffers one or more writable buffers to flush and close
+ /// @throws IOException the first exception encountered while flushing or
closing, with the rest suppressed
+ public static void flushAndClose(PinotDataBuffer... buffers)
Review Comment:
Good point, done in 6bd5361: renamed to `closeAll`, with a Javadoc saying it
only calls `close()` on each buffer and aggregates the failures.
`FilePerIndexDirectory.close()` uses it now too.
--
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]