ccding commented on a change in pull request #10405:
URL: https://github.com/apache/kafka/pull/10405#discussion_r605902276
##########
File path: clients/src/main/java/org/apache/kafka/common/record/FileRecords.java
##########
@@ -195,6 +199,17 @@ public int append(MemoryRecords records) throws
IOException {
*/
public void flush() throws IOException {
channel.force(true);
+ if (needFlushParentDir.getAndSet(false)) {
+ Utils.flushParentDir(file.toPath());
+ }
+ }
+
+ /**
+ * Flush the parent directory of a file to the physical disk, which makes
sure the file is accessible after crashing.
+ */
+ public void flushParentDir() throws IOException {
+ needFlushParentDir.set(false);
Review comment:
Same as above.
Set flag first to prevent other threads from calling `flush` concurrently.
##########
File path: clients/src/main/java/org/apache/kafka/common/record/FileRecords.java
##########
@@ -195,6 +199,17 @@ public int append(MemoryRecords records) throws
IOException {
*/
public void flush() throws IOException {
channel.force(true);
+ if (needFlushParentDir.getAndSet(false)) {
+ Utils.flushParentDir(file.toPath());
+ }
+ }
+
+ /**
+ * Flush the parent directory of a file to the physical disk, which makes
sure the file is accessible after crashing.
+ */
+ public void flushParentDir() throws IOException {
+ needFlushParentDir.set(false);
Review comment:
Same as above.
Setting flag first to prevent other threads from calling `flush`
concurrently.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]