-
Notifications
You must be signed in to change notification settings - Fork 275
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
State Build implementation for File Copy based replication #2954
Conversation
80d1bce
to
1124d46
Compare
0948730
to
ef290ec
Compare
6e10bcf
to
944356e
Compare
ef290ec
to
350dd47
Compare
b608e52
to
2e147ea
Compare
4f7c463
to
664acbe
Compare
// create a bootstrap-in-progress file to distinguish it from regular stores (the file will be checked during | ||
// BOOTSTRAP -> STANDBY transition) | ||
createBootstrapFileIfAbsent(replica); | ||
logger.info("New store is successfully added into DiskManager."); |
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.
nit: We should log partitionId in this log.
succeed = true; | ||
} | ||
} catch (Exception e) { | ||
logger.error("Failed to start new added store {} or add requirements to disk allocator", replica.getPartitionId(), |
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.
Log statement needs to be tweaked as we are not making a call to diskSpaceAllocator
now.
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java
Show resolved
Hide resolved
Store store = dm.getStore(newPartition, false); | ||
MockId id1 = addRandomBlobToStore(store, 100, Utils.Infinite_Time); | ||
MockId id2 = addRandomBlobToStore(store, 200, Utils.Infinite_Time); | ||
// Create storage manager again to create disk managers again |
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.
For my understanding, why is shutting down the storageManager and re-initiating it, relevant / necessary?
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 need to shut it down to ensure that BlobStores are shut down and state build is able to start the BlobStores again. This is to test the flow where existing blobs are written to disk and then building state is attempted by adding a store via stateBuild flow.
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java
Show resolved
Hide resolved
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java
Show resolved
Hide resolved
* @throws Exception | ||
*/ | ||
@Test | ||
public void buildStateForFileCopyFailureToAddBlobStoreTest() throws Exception { |
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.
Rename: AddingDuplicateBlobStoreShouldFailTest*
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java
Show resolved
Hide resolved
ambry-store/src/main/java/com/github/ambry/store/StorageManager.java
Outdated
Show resolved
Hide resolved
*/ | ||
@Override | ||
public boolean addBlobStoreForFileCopy(ReplicaId replica) { | ||
if (partitionToDiskManager.containsKey(replica.getPartitionId())) { |
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 will get added as part of pre-file store, so it might occur that the this always returns true. We need to check for the existence of store here explicitely.
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 should instead check below map for existence of store in disk manager.
private final ConcurrentHashMap<PartitionId, BlobStore> stores = new ConcurrentHashMap<>();
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.
Yes, diskmanager will be started already in pre-filecopy steps. Instead, I have put the check of partitionToDiskManager not having the partitionId key and fetching the diskManager from this map itself. Checking of store's existence is handled in the addBlobStoreForFileCopy call.
664acbe
to
76073d6
Compare
logger.error("Failed to add new store into DiskManager"); | ||
return false; | ||
} | ||
partitionToDiskManager.put(replica.getPartitionId(), diskManager); |
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 should already be present when we add the Blob Store after file copy.
Steps happening before this:
- Addition of Replica object.
- File Copy Trigger -> This will add FileStore in StorageManager which goes through DiskManager. This step also should create an entry in partitionToDiskManager.
82b5da6
to
1b97cc7
Compare
compactionManager.addBlobStore(store); | ||
// add new created store into in-memory data structures. | ||
stores.put(replica.getPartitionId(), store); | ||
partitionToReplicaMap.put(replica.getPartitionId(), replica); |
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.
As the name suggest, we should be adding an entry to this map much sooner than after the file copy finishes.
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.
Done, we should handle it in prefilecopy. Please make a note.
logger.error("Failed to add new store into DiskManager"); | ||
return false; | ||
} | ||
partitionNameToReplicaId.put(replica.getPartitionId().toPathString(), replica); |
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.
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.
Done, we should handle it in prefilecopy. Please make a note.
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java
Show resolved
Hide resolved
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.
Added couple of comments.
6d69c20
to
4098a89
Compare
4098a89
to
f32df47
Compare
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 PR handles initializing BlobStore with Log, Index, BlobStoreCompactor, RemoteTokenTracker, etc post filecopy is completed in the filecopy based replication.
Bootstrap State Build Design Doc
Key Changes:
Test Coverage: