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

[server] Dropping unassigned partitions #1196

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

kristyelee
Copy link

@kristyelee kristyelee commented Sep 24, 2024

Summary, imperative, start upper case, don't end with a period

The goal is to remove unassigned partitions that are on disk state

This involves storage service and engine, which upon starting (constructed), will go through folders on disk and verify status of folders
Helix's ideal state is used for consulting partitions and their assignment
The change proposed includes defining a function in VeniceServer that goes through partitions in idealState and compares to partitions in storageEngine
StorageEngine object initialization is also being updated to run the new function that performs this verification.

Resolves #650

How was this PR tested?

Will write corresponding test.
EDIT: A unit test has been written.

Does this PR introduce any user-facing changes?

  • No. You can skip the rest of this section.
  • Yes. Make sure to explain your proposed changes and call out the behavior change.

@kristyelee kristyelee marked this pull request as draft September 24, 2024 02:37
@kvargha
Copy link
Contributor

kvargha commented Sep 24, 2024

It looks like spotBugs is failing.

If you run this locally, you'll be able to read the report to see what's wrong.
./gradlew :services:venice-server:spotbugsMain

Make sure to build before running this.

@kristyelee kristyelee force-pushed the kristy_lee/650 branch 2 times, most recently from 3e496b1 to 56e7711 Compare September 25, 2024 18:58
@nisargthakkar nisargthakkar changed the title [venice-server] Dropping unassigned partitions [server] Dropping unassigned partitions Oct 19, 2024
Drop unassigned partitions for store upon VeniceServer shutdown
Unassigned partitions for store are dropped upon VeniceServer shutdown
Remove storage partitions not assigned to host

This involves updates in:
1. Updating a function in StorageService to consult ideal state
2. Hostname comparison for each partition
3. Resolution of empty assignment in ideal state
4. Unit test
@kristyelee kristyelee force-pushed the kristy_lee/650 branch 2 times, most recently from 8ceb7cc to 3364f13 Compare November 4, 2024 23:11
@kristyelee
Copy link
Author

The check over which storage partitions to persist is moved to the shutdown phase of VeniceServer which was discussed.

Shutdown phase contains call to storageService.checkWhetherStoragePartitionsShouldBeKeptOrNot. Services are also stopped when VeniceServer shuts down.

[server] Remove storage partitions not assigned to host.
Drop unassigned partitions.
Update to server to verify partitions to persist.

This involves:
1. Updating a function in StorageService to consult ideal state
2. Hostname comparison for each partition
3. Correct call in VeniceServer
4. Unit test
5. Integration test
@@ -209,6 +209,9 @@ public void testStartServerAndShutdownWithPartitionAssignmentVerification() {
repository = server.getVeniceServer().getStorageService().getStorageEngineRepository();
Assert.assertEquals(repository.getAllLocalStorageEngines().size(), 1);
Assert.assertEquals(storageService.getStorageEngine(storeName).getPartitionIds().size(), 0);
server.getVeniceServer().getStorageService().removeStorageEngine(storeName);
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic should be done in checkWhetherStoragePartitionsShouldBeKeptOrNot.

If we've deleted all partitions for a storageEngine, we should call removeStorageEngine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since removeStorageEngine, is now called in checkWhetherStoragePartitionsShouldBeKeptOrNot, you can remove line 212. Once that's in I'll kick it off to Zac.

Comment on lines +391 to +404
if (idealState != null) {
Map<String, Map<String, String>> mapFields = idealState.getRecord().getMapFields();
for (Integer partitionId: storageEnginePartitionIds) {
String partitionDbName = storeName + "_" + partitionId;
if (!mapFields.containsKey(partitionDbName)
|| !mapFields.get(partitionDbName).containsKey(instanceHostName)) {
storageEngine.dropPartition(partitionId);
}
}
if (storageEngine.getPartitionIds().isEmpty()) {
removeStorageEngine(storeName);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

idealState can be null if the store doesn't exist anymore. I'll leave it up to @ZacAttack whether or not we should remove the storageEngine in the else conditional.

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.

[BUG] Reconcile on disk state with assigned partitions for given resource and delete unused partitions
3 participants