-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-28839: Handle all types of exceptions during retrieval of bucket-cache from persistence. #6250
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
HBASE-28839: Handle all types of exceptions during retrieval of bucket-cache from persistence. #6250
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,6 @@ | |
| import org.apache.hadoop.hbase.io.hfile.BlockType; | ||
| import org.apache.hadoop.hbase.io.hfile.CacheableDeserializerIdManager; | ||
| import org.apache.hadoop.hbase.io.hfile.HFileBlock; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.apache.hadoop.hbase.util.Pair; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
|
|
@@ -51,51 +50,53 @@ private BucketProtoUtils() { | |
| } | ||
|
|
||
| static BucketCacheProtos.BucketCacheEntry toPB(BucketCache cache, | ||
| BucketCacheProtos.BackingMap backingMap) { | ||
| BucketCacheProtos.BackingMap.Builder backingMapBuilder) { | ||
| return BucketCacheProtos.BucketCacheEntry.newBuilder().setCacheCapacity(cache.getMaxSize()) | ||
| .setIoClass(cache.ioEngine.getClass().getName()) | ||
| .setMapClass(cache.backingMap.getClass().getName()) | ||
| .putAllDeserializers(CacheableDeserializerIdManager.save()) | ||
| .putAllCachedFiles(toCachedPB(cache.fullyCachedFiles)).setBackingMap(backingMap) | ||
| .putAllCachedFiles(toCachedPB(cache.fullyCachedFiles)) | ||
| .setBackingMap(backingMapBuilder.build()) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to pass an empty backingmap here otherwise we see an exception of an incomplete object. Hence, we just pass an empty backing map along with the metadata. Subsequently, we persist all entries of the backing map in chunks.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need a builder, just pass an empty map. Or, since we don't persist any map entries within the BucketCacheEntry proto object, just remove the map from the protobuf message. We already changed the persistent file format on HBASE-28805, as long as this can land on all related branches whilst HBASE-28805 has not made into any release, we are free to change the format.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @wchevreuil, we will need to retain the old format of protobuf message to maintain the backward compatibility. Hence, the we cannot change the protobuf message. We can reuse this protobuf message by persisting an empty backing map instead of introducing a new version. |
||
| .setChecksum(ByteString | ||
| .copyFrom(((PersistentIOEngine) cache.ioEngine).calculateChecksum(cache.getAlgorithm()))) | ||
| .build(); | ||
| } | ||
|
|
||
| public static void serializeAsPB(BucketCache cache, FileOutputStream fos, long chunkSize, | ||
| long numChunks) throws IOException { | ||
| int blockCount = 0; | ||
| int chunkCount = 0; | ||
| int backingMapSize = cache.backingMap.size(); | ||
| BucketCacheProtos.BackingMap.Builder builder = BucketCacheProtos.BackingMap.newBuilder(); | ||
|
|
||
| public static void serializeAsPB(BucketCache cache, FileOutputStream fos, long chunkSize) | ||
| throws IOException { | ||
| // Write the new version of magic number. | ||
| fos.write(PB_MAGIC_V2); | ||
| fos.write(Bytes.toBytes(chunkSize)); | ||
| fos.write(Bytes.toBytes(numChunks)); | ||
|
|
||
| BucketCacheProtos.BackingMap.Builder builder = BucketCacheProtos.BackingMap.newBuilder(); | ||
| BucketCacheProtos.BackingMapEntry.Builder entryBuilder = | ||
| BucketCacheProtos.BackingMapEntry.newBuilder(); | ||
|
|
||
| // Persist the metadata first. | ||
| toPB(cache, builder).writeDelimitedTo(fos); | ||
|
|
||
| int blockCount = 0; | ||
| // Persist backing map entries in chunks of size 'chunkSize'. | ||
| for (Map.Entry<BlockCacheKey, BucketEntry> entry : cache.backingMap.entrySet()) { | ||
| blockCount++; | ||
| entryBuilder.clear(); | ||
| entryBuilder.setKey(BucketProtoUtils.toPB(entry.getKey())); | ||
| entryBuilder.setValue(BucketProtoUtils.toPB(entry.getValue())); | ||
| builder.addEntry(entryBuilder.build()); | ||
|
|
||
| if (blockCount % chunkSize == 0 || (blockCount == backingMapSize)) { | ||
| chunkCount++; | ||
| if (chunkCount == 1) { | ||
| // Persist all details along with the first chunk into BucketCacheEntry | ||
| BucketProtoUtils.toPB(cache, builder.build()).writeDelimitedTo(fos); | ||
| } else { | ||
| // Directly persist subsequent backing-map chunks. | ||
| builder.build().writeDelimitedTo(fos); | ||
| } | ||
| if (blockCount < backingMapSize) { | ||
| builder.clear(); | ||
| } | ||
| addEntryToBuilder(entry, entryBuilder, builder); | ||
| if (blockCount % chunkSize == 0) { | ||
| builder.build().writeDelimitedTo(fos); | ||
| builder.clear(); | ||
| } | ||
| } | ||
| // Persist the last chunk. | ||
| if (builder.getEntryList().size() > 0) { | ||
| builder.build().writeDelimitedTo(fos); | ||
| } | ||
| } | ||
|
|
||
| private static void addEntryToBuilder(Map.Entry<BlockCacheKey, BucketEntry> entry, | ||
| BucketCacheProtos.BackingMapEntry.Builder entryBuilder, | ||
| BucketCacheProtos.BackingMap.Builder builder) { | ||
| entryBuilder.clear(); | ||
| entryBuilder.setKey(BucketProtoUtils.toPB(entry.getKey())); | ||
| entryBuilder.setValue(BucketProtoUtils.toPB(entry.getValue())); | ||
| builder.addEntry(entryBuilder.build()); | ||
| } | ||
|
|
||
| private static BucketCacheProtos.BlockCacheKey toPB(BlockCacheKey key) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.