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

Fix NullPointerException and 'no more capacity' issues in blob store #1168

Merged
merged 2 commits into from
May 6, 2019

Conversation

jsjtzyy
Copy link
Contributor

@jsjtzyy jsjtzyy commented May 6, 2019

  1. NPE occurs when error message of captured IOException is null. In
    this case, we should use Objects.equals to compare error string.
  2. 'no more capacity' issue occurs when new log segment creation failed,
    however, the code didn't restore the counter of remainingUnallocatedSegments.
    This patch will catch such failure and restore counter as well as clean
    up the allocated file.

This pr will address #1167

@jsjtzyy jsjtzyy requested review from zzmao and cgtz May 6, 2019 17:53
@jsjtzyy jsjtzyy self-assigned this May 6, 2019
@zzmao
Copy link
Contributor

zzmao commented May 6, 2019

Thanks for fixing it!

@codecov-io
Copy link

Codecov Report

Merging #1168 into master will decrease coverage by 0.13%.
The diff coverage is 29.72%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1168      +/-   ##
============================================
- Coverage     70.03%   69.89%   -0.14%     
+ Complexity     5352     5347       -5     
============================================
  Files           426      426              
  Lines         32650    32654       +4     
  Branches       4142     4143       +1     
============================================
- Hits          22865    22825      -40     
- Misses         8653     8686      +33     
- Partials       1132     1143      +11
Impacted Files Coverage Δ Complexity Δ
.../main/java/com.github.ambry.store/HardDeleter.java 81.58% <0%> (+0.14%) 42 <0> (ø) ⬇️
...c/main/java/com.github.ambry.store/LogSegment.java 86.66% <0%> (+1.42%) 50 <0> (ø) ⬇️
...n/java/com.github.ambry.store/PersistentIndex.java 92.37% <100%> (+0.26%) 197 <0> (+1) ⬆️
...tore/src/main/java/com.github.ambry.store/Log.java 93.1% <27.77%> (-5.33%) 60 <0> (ø)
...main/java/com.github.ambry.store/IndexSegment.java 86.1% <42.85%> (+0.14%) 106 <0> (+1) ⬆️
...c/main/java/com.github.ambry.network/Selector.java 77.22% <0%> (-3.48%) 47% <0%> (-1%)
...java/com.github.ambry.store/CompactionManager.java 87.33% <0%> (-2.67%) 19% <0%> (ø)
...github.ambry.rest/AsyncRequestResponseHandler.java 88.59% <0%> (-2.29%) 23% <0%> (ø)
...in/java/com.github.ambry.store/BlobStoreStats.java 71.13% <0%> (-2.27%) 103% <0%> (-2%)
.../main/java/com.github.ambry.store/ScanResults.java 81.25% <0%> (-1.57%) 16% <0%> (-1%)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aaf8d92...2c0bcf1. Read the comment docs.

@@ -906,8 +908,8 @@ private void readFromFile(File fileToRead, Journal journal) throws StoreExceptio
StoreErrorCodes.Index_Creation_Failure);
}
} catch (IOException e) {
StoreErrorCodes errorCode =
e.getMessage().equals(StoreException.IO_ERROR_STR) ? StoreErrorCodes.IOError : StoreErrorCodes.Unknown_Error;
StoreErrorCodes errorCode = Objects.equals(e.getMessage(), StoreException.IO_ERROR_STR) ? StoreErrorCodes.IOError
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic for going from IOException to StoreErrorCode is repeated in a lot of places. Since this is a bugfix, you don't have to address it now, but it would be good to move this into a static method in StoreException in the future.

1. NPE occurs when error message of captured IOException is null. In
this case, we should use Objects.equals to compare error string.
2. 'no more capacity' issue occurs when new log segment creation failed,
however, the code didn't restore the counter of remainingUnallocatedSegments.
This patch will catch such failure and restore counter as well as clean
up the allocted file.
@jsjtzyy jsjtzyy force-pushed the fix-exception-NPE branch from 2c0bcf1 to e32ce25 Compare May 6, 2019 20:48
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.

4 participants