-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-8418. Lease Manager unsafe method fix #4578
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
Conversation
|
@sumitagrawl there are multiple test failures, please check |
adoroszlai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sumitagrawl thanks for working on this. It's not clear what the problem was and how the patch is supposed to fix it.
I suspect intermittent failure in TestCloseContainerEventHandler could be the result of the problem being fixed:
[INFO] Running org.apache.hadoop.hdds.scm.container.TestCloseContainerEventHandler
Error: Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 6.357 s <<< FAILURE! - in org.apache.hadoop.hdds.scm.container.TestCloseContainerEventHandler
Error: org.apache.hadoop.hdds.scm.container.TestCloseContainerEventHandler.testCloseContainerWithDelayByLeaseManager Time elapsed: 4.528 s <<< FAILURE!
Wanted but not invoked:
eventPublisher.fireEvent(
TypedEvent{payloadType=CommandForDatanode, name='Datanode_Command'},
<Capturing argument>
);
-> at org.apache.hadoop.hdds.scm.container.TestCloseContainerEventHandler.testCloseContainerWithDelayByLeaseManager(TestCloseContainerEventHandler.java:151)
Actually, there were zero interactions with this mock.
Synchronization in Lease is very mixed after this patch:
- write to
expiredis synchronized (invalidate()), but read is not (hasExpired()), except when called from other synchronized method callbacksis asynchronizedList, item addition is also synchronized onLease(registerCallback()), butgetCallbacks()returns the list as is, and iteration happens without either lockleaseTimeoutis atomic, write is also synchronized (renew()), but read is not (getLeaseLifeTime())
Several methods called from LeaseManager are also protected by synchronization in that class.
Instead of adding a few synchronized keywords here and there, it would be great to make it consistent.
|
The bug is the |
| } | ||
|
|
||
| private synchronized void handleTimeout(EventPublisher publisher, | ||
| private synchronized Void handleTimeout(EventPublisher publisher, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get this part, what is the impact of changing void-> Void and returning null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callback as getting registered has return type is Callback with "Void" Object, so this gives error if return type mismatch,
Syntax for acquire: public synchronized Lease<T> acquire( T resource, Callable<Void> callback)
Below is error if we keep void:
Bad return type in lambda expression: void cannot be converted to Void
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it , looks like autoboxing won't happen for void type. Thanks for explaining
sadanand48
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Thanks @sumitagrawl for the fix, @adoroszlai @szetszwo for reviewing. |
What changes were proposed in this pull request?
registerCallback in Lease is not safe if done after lease expiry in parallel, so this callback will never be registered. Removed this method exposer.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-8418
How was this patch tested?
UT case and IT for checking any impact