- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.4k
HBASE-27203 Clean up error-prone findings in hbase-client [branch-2] #4651
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
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.
Notable findings exclusive to branch-2.
| handleException(); | ||
| if (this.closed) { | ||
| return null; | ||
| try { | 
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.
We were missing an inner try here.
|  | ||
| @Override | ||
| public void close() { | ||
| lock.lock(); | 
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.
Not a bug like above but still a nit.
| * Global nonceGenerator shared per client. Currently there's no reason to limit its scope. Once | ||
| * it's set under nonceGeneratorCreateLock, it is never unset or changed. | ||
| */ | ||
| // XXX: It is a bad pattern to assign a value to a static field from a constructor. However | 
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.
Declined to fix the issue because we'd have to use a Configuration instance at static class init time, not the Configuration that gets passed into the Constructor. However, marked it as a code smell with XXX.
| public void mergeRegions(final byte[] nameOfRegionA, final byte[] nameOfRegionB, | ||
| final boolean forcible) throws IOException { | ||
| mergeRegionsAsync(nameOfRegionA, nameOfRegionB, forcible); | ||
| try { | 
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.
mergeRegions will return immediately without waiting for or surfacing any exception from the operation. This seems wrong. We don't expect to wait for the master to complete the merge but we would expect to surface an IOException from the RPC. Yet, it is a semantic change over previously released versions. For discussion.
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.
IIRC this is a known issue. You can see the comments in the Admin interface.
  /**
   * Merge two regions. Asynchronous operation.
   * @param nameOfRegionA encoded or full name of region a
   * @param nameOfRegionB encoded or full name of region b
   * @param forcible      <code>true</code> if do a compulsory merge, otherwise we will only merge
   *                      two adjacent regions
   * @throws IOException if a remote or network exception occurs
   * @deprecated Since 2.0. Will be removed in 3.0. Use
   *             {@link #mergeRegionsAsync(byte[], byte[], boolean)} instead.
   */
  @Deprecated
  void mergeRegions(byte[] nameOfRegionA, byte[] nameOfRegionB, boolean forcible)
    throws IOException;
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'm not sure an IOException will get thrown as expected because we don't get() the Future. On the other hand this has been the behavior for a long time. I will stick to warning cleanups and come back to this later.
| // call out to master to do split now | ||
| splitRegionAsync(r, splitPoint); | ||
| try { | ||
| splitRegionAsync(r, splitPoint).get(); | 
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.
split will return immediately without waiting for or surfacing any exception from the operation. This seems wrong. We don't expect to wait for the split to complete but we would expect to surface an IOException from the RPC. Yet, it is a semantic change over previously released versions. For discussion.
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.
Should be the same with mergeRegions method.
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.
Same, will come back to this later.
| return this.maxLatency.getAndSet(0); | ||
| } | ||
|  | ||
| @SuppressWarnings("FutureReturnValueIgnored") | 
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.
Same
| private long fastFailClearingTimeMilliSec; | ||
|  | ||
| private final ThreadLocal<MutableBoolean> threadRetryingInFastFailMode = new ThreadLocal<>(); | ||
| private static final ThreadLocal<MutableBoolean> threadRetryingInFastFailMode = | 
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.
ThreadLocals should to be class fields not instance fields. Otherwise the coder may get the false impression interactions with the thread local is also scoped to the instance. They are not, they are scoped to the thread.
|  | ||
| /** | ||
| * Set the tracker that should be used for tracking statistics about the server | ||
| * @deprecated Does nothing. Since 2.5.0, will be removed in 4.0.0. | 
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.
Remove this in 3.0.0 instead?
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.
This class is IA.Private so we are free to remove it at any time.
| throw new IOException("Imposible? Arrive at an unreachable line..."); | ||
| } | ||
|  | ||
| @SuppressWarnings("FutureReturnValueIgnored") | 
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.
Suppressed here because scheduling the callable returns a future we don't care about.
|  | ||
| private boolean reloginInProgress; | ||
|  | ||
| @SuppressWarnings("FutureReturnValueIgnored") | 
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.
Suppressed here because the scheduling returns a future we don't care about.
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| Rolled back the HBaseAdmin changes called out above, just cleanups now, proceeding to merge. I will file a follow up for that, with a more considered set of changes. | 
…4651) Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Viraj Jasani <[email protected]>
No description provided.