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

[bug][coordinator/kv] delete remote kv dir for table on coordinator server #297

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

Conversation

Vipamp
Copy link
Contributor

@Vipamp Vipamp commented Jan 1, 2025

Purpose

Linked issue: close #296

Tests

KvSnapshotITCase#testKvSnapshotAndDelete

API and Format

Documentation

@Vipamp Vipamp changed the title delete remote kv dir for table on coordinator server [bug][coordinator/kv] delete remote kv dir for table on coordinator server Jan 1, 2025
@luoyuxia
Copy link
Collaborator

luoyuxia commented Jan 6, 2025

@Vipamp Is this pr ready for review?

@Vipamp
Copy link
Contributor Author

Vipamp commented Jan 6, 2025

@Vipamp Is this pr ready for review?

Yes,i have finished it,i am sorry that i didn't tell you for review.

Copy link
Collaborator

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

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

@Vipamp Thanks for the pr. Left some comments. PTAL

*
* </pre>
*
* @param remoteKvOrLogBaseDir - the remote kv snapshots or log segments root dir of specific
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
* @param remoteKvOrLogBaseDir - the remote kv snapshots or log segments root dir of specific
* @param remoteKvOrLogBaseDir - the remote kv snapshots or log segments root dir of tables

this.coordinatorEventProcessor =
new CoordinatorEventProcessor(
zkClient,
remoteStorageHandler,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: not to define local variable, just pass new RemoteStorageHandler(conf);

import org.slf4j.LoggerFactory;

import java.io.IOException;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add comments for this class..


import java.io.IOException;

public class RemoteStorageHandler {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename it to RemoteStorageCleaner ? as now it's only for delete remote storage dir....

this.remoteFileSystem = remoteKvDir.getFileSystem();
}

public void createTableKvDir(TablePath tablePath, long tableId) throws IOException {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not introudce this method since it's only for testing... introduce code used only in testing will make it hard to maintain.


private void deleteDir(FsPath fsPath) {
try {
if (isDirExists(fsPath)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: just use remoteFileSystem.exists(fsPath)

}
}

private FsPath tableKvDir(TablePath tablePath, long tableId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
private FsPath tableKvDir(TablePath tablePath, long tableId) {
private FsPath tableKvRemoteDir(TablePath tablePath, long tableId) {

remoteFileSystem.mkdirs(tableKvDir(tablePath, tableId));
}

public void deleteTable(TablePath tablePath, long tableId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public void deleteTable(TablePath tablePath, long tableId) {
public void deleteTableRemoteDir(TablePath tablePath, long tableId) {

import java.nio.file.Path;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add comments for this class... Otherwise, checkstyle will fail

@@ -159,6 +172,9 @@ void testDeleteTable() throws Exception {
assertThat(zookeeperClient.getTableAssignment(tableId)).isEmpty();
// the table will also be removed from coordinator context
assertThat(coordinatorContext.getAllReplicasForTable(tableId)).isEmpty();

// the table's remote kv root dir should be removed.
assertThat(remoteStorageHandler.isTableKvDirExists(DATA1_TABLE_PATH_PK, tableId)).isFalse();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also add IT to make sure drop table will also delete kv remote dir.
Maybe we can add in KvSnapshotITCase

@Vipamp
Copy link
Contributor Author

Vipamp commented Jan 7, 2025

@Vipamp Thanks for the pr. Left some comments. PTAL

Thinks for your comments,i will update those codes later.

@Vipamp
Copy link
Contributor Author

Vipamp commented Jan 11, 2025

@luoyuxia Hi, I have updated those code, PTAL, thinks.

Copy link
Collaborator

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

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

@Vipamp Thanks for updating.. Left minor comments.. Should be ready to be merged in next iteration..

}

@Test
void testKvSnapshot() throws Exception {
void testKvSnapshotAndDeleteForTabletServer() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
void testKvSnapshotAndDeleteForTabletServer() throws Exception {
void testKvSnapshotAndDelete() throws Exception {

completedSnapshotHandleStore =
new ZooKeeperCompletedSnapshotHandleStore(
FLUSS_CLUSTER_EXTENSION.getZooKeeperClient());
CoordinatorServer coordinatorServer = FLUSS_CLUSTER_EXTENSION.getCoordinatorServer();
Field coordinatorEventProcessorField =
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's hack to get CoordinatorEventProcessor by reflection..

.isEqualTo(6));
}
}
eventProcessor.process(new DropTableEvent(tableId, false));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just use CoordinatorService#dropTable to mock the deletion of table? Move the logic to test method testKvSnapshotAndDeleteForTabletServer so that
1: the test can be removed
2: we can remove the code in method testKvSnapshotAndDeleteForTabletServer

CompletableFuture<List<StopReplicaResultForBucket>> future =
                        new CompletableFuture<>();
                server.getReplicaManager()
                        .stopReplicas(
                                INITIAL_COORDINATOR_EPOCH,
                                Collections.singletonList(
                                        new StopReplicaData(
                                                tableBucket, true, INITIAL_COORDINATOR_EPOCH, 1)),
                                future::complete);

and replace it with method CoordinatorService#dropTable directly to simpify the testing..

@Vipamp
Copy link
Contributor Author

Vipamp commented Jan 18, 2025

hi, @luoyuxia I have updated the codes, PTAL, thinks.

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.

[Improve] Delete table's remote kv directory for coordinator server.
2 participants