Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-13391: don't fsync directory on Windows OS #11426

Merged
merged 2 commits into from
Oct 25, 2021

Conversation

showuon
Copy link
Contributor

@showuon showuon commented Oct 22, 2021

In #10680, we added fysnc on dir to maintain crash consistency. But, it looks like Windows OS doesn't support fsync on directory. The same issues also happen on LUCENE and HDFS projects. And the way they fix it is pretty much the same: to skip fsync directory on Windows OS. Here are the patches for both LUCENE-5588 and HDFS-13586.

I followed their way to fix this issue. No tests added since it's just an OS check added, no logic change.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@showuon
Copy link
Contributor Author

showuon commented Oct 22, 2021

@ccding @junrao , please help review the PR. Thank you.

Copy link
Contributor

@ccding ccding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. LGTM

@@ -948,10 +948,12 @@ public static void atomicMoveWithFallback(Path source, Path target, boolean need
/**
* Flushes dirty directories to guarantee crash consistency.
*
* Note: We don't fsync directory on Windows OS because it'll throw AccessDeniedException (KAFKA-13391)
Copy link
Contributor

@ccding ccding Oct 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: directory -> directories, because -> because otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. Updated.

Copy link
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@showuon : Thanks for the PR. LGTM

@junrao junrao merged commit 145392b into apache:trunk Oct 25, 2021
junrao pushed a commit that referenced this pull request Oct 25, 2021
Reviewers: Cong Ding <cong@ccding.com>, Jun Rao <junrao@gmail.com>
* @throws IOException if flushing the directory fails.
*/
public static void flushDir(Path path) throws IOException {
if (path != null) {
if (path != null && !OperatingSystem.IS_WINDOWS) {
try (FileChannel dir = FileChannel.open(path, StandardOpenOption.READ)) {
dir.force(true);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a file lock on this file that causes the issue, which might be hiding another issue even on other platforms.

xdgrulez pushed a commit to xdgrulez/kafka that referenced this pull request Dec 22, 2021
Reviewers: Cong Ding <cong@ccding.com>, Jun Rao <junrao@gmail.com>
@mosesonline
Copy link

When will this PR will be released in the 3.0.1/X releases?

@showuon
Copy link
Contributor Author

showuon commented Feb 16, 2022

@mosesonline , here's the release plan for v3.0.1. FYI
https://cwiki.apache.org/confluence/display/KAFKA/Release+Plan+3.0.1

lmr3796 pushed a commit to lmr3796/kafka that referenced this pull request Jun 2, 2022
Reviewers: Cong Ding <cong@ccding.com>, Jun Rao <junrao@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants