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

HDFS-15875. Check whether file is being truncated before truncate #2746

Merged
merged 4 commits into from
Mar 10, 2021

Conversation

ferhui
Copy link
Contributor

@ferhui ferhui commented Mar 5, 2021

NOTICE

Please create an issue in ASF JIRA before opening a pull request,
and you need to set the title of the pull request which starts with
the corresponding JIRA issue number. (e.g. HADOOP-XXXXX. Fix a typo in YYY.)
For more details, please see https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute

@ferhui
Copy link
Contributor Author

ferhui commented Mar 5, 2021

@ayushtkn Could you please help to review this? Thanks

Copy link
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

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

Thanx @ferhui for the fix, The prod changes LGTM. Minor stuff in the test.
Apart, I see there are bunch of sleeps, can you give a check if the amount can be reduced by means of any config, or if there is any scope of using GenericTestUtil.waitFor in the test, just to ensure this test doesn't go flaky, and do increase the test timeout also a bit.

Comment on lines 270 to 274
try {
fs.truncate(p, data.length - 2);
} catch (IOException e) {
//GenericTestUtils.assertExceptionContains("is being truncated.", e);
}
Copy link
Member

Choose a reason for hiding this comment

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

Can use LambdaTestUtils.

    LambdaTestUtils.intercept(RemoteException.class,
        "/testTruncateTwiceTogether/file is being truncated",
        () -> fs.truncate(p, data.length - 2));

ThreadLocalRandom.current().nextBytes(data);
writeContents(data, data.length, p);

DataNodeFaultInjector originInjector = DataNodeFaultInjector.get();
Copy link
Member

Choose a reason for hiding this comment

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

Is this used somewhere?

// Bigger than soft lease period.
Thread.sleep(65000);
} catch (InterruptedException e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

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

No need to print the trace, if possible add Exception to method signature and remove this try-catch, else ignore the exception

@ferhui
Copy link
Contributor Author

ferhui commented Mar 8, 2021

@ayushtkn Thanks for review ! Will commit the fix soon!

Comment on lines 701 to 705
fail("Truncate must fail since a truncate is already in progress.");
} catch (IOException expected) {
GenericTestUtils.assertExceptionContains(
"Failed to TRUNCATE_FILE", expected);
"/dir/testTruncateFailure is being truncated", expected);
}
Copy link
Member

Choose a reason for hiding this comment

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

What is the difference between this case and ours? Why doesn't this exception triggers for our case? and can we accommodate our fix to the check throwing this exception

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ayushtkn Thanks for review!
This case happens with the same lease holder when enter recoverLeaseInternal. And our fix throw exception before enter recoverLeaseInternal. Our UT has 2 clients with different client names.
Will upload fix to throw the same exception.

@ferhui ferhui closed this Mar 9, 2021
@ferhui ferhui reopened this Mar 9, 2021
@ferhui
Copy link
Contributor Author

ferhui commented Mar 10, 2021

@ayushtkn Any further questions? Thanks!

Copy link
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

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

Changes LGTM

@ferhui ferhui merged commit 6a55bae into apache:trunk Mar 10, 2021
@ferhui
Copy link
Contributor Author

ferhui commented Mar 10, 2021

@ayushtkn Thanks for review !
Merged

@ferhui ferhui deleted the HDFS-15875 branch March 10, 2021 06:11
asfgit pushed a commit that referenced this pull request Mar 11, 2021
asfgit pushed a commit that referenced this pull request Mar 11, 2021
asfgit pushed a commit that referenced this pull request Mar 11, 2021
kiran-maturi pushed a commit to kiran-maturi/hadoop that referenced this pull request Nov 24, 2021
Xushaohong pushed a commit to Xushaohong/hadoop that referenced this pull request Jul 20, 2022
jojochuang pushed a commit to jojochuang/hadoop that referenced this pull request May 23, 2023
…truncate (apache#2746)

(cherry picked from commit 6a55bae)
Change-Id: I0de89a5fd355f06e630ecfa59c91c1899d3d376d
(cherry picked from commit d13eb53)
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.

2 participants