-
Notifications
You must be signed in to change notification settings - Fork 222
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
base: main
Are you sure you want to change the base?
Conversation
@Vipamp Is this pr ready for review? |
Yes,i have finished it,i am sorry that i didn't tell you for review. |
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.
@Vipamp Thanks for the pr. Left some comments. PTAL
* | ||
* </pre> | ||
* | ||
* @param remoteKvOrLogBaseDir - the remote kv snapshots or log segments root dir of specific |
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:
* @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, |
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: not to define local variable, just pass new RemoteStorageHandler(conf)
;
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
|
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.
Please add comments for this class..
|
||
import java.io.IOException; | ||
|
||
public class RemoteStorageHandler { |
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 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 { |
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.
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)) { |
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: just use remoteFileSystem.exists(fsPath)
} | ||
} | ||
|
||
private FsPath tableKvDir(TablePath tablePath, long tableId) { |
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.
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) { |
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.
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; | ||
|
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.
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(); |
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.
Also add IT to make sure drop table will also delete kv remote dir.
Maybe we can add in KvSnapshotITCase
Thinks for your comments,i will update those codes later. |
@luoyuxia Hi, I have updated those code, PTAL, thinks. |
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.
@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 { |
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.
void testKvSnapshotAndDeleteForTabletServer() throws Exception { | |
void testKvSnapshotAndDelete() throws Exception { |
completedSnapshotHandleStore = | ||
new ZooKeeperCompletedSnapshotHandleStore( | ||
FLUSS_CLUSTER_EXTENSION.getZooKeeperClient()); | ||
CoordinatorServer coordinatorServer = FLUSS_CLUSTER_EXTENSION.getCoordinatorServer(); | ||
Field coordinatorEventProcessorField = |
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.
It's hack to get CoordinatorEventProcessor
by reflection..
.isEqualTo(6)); | ||
} | ||
} | ||
eventProcessor.process(new DropTableEvent(tableId, false)); |
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.
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..
hi, @luoyuxia I have updated the codes, PTAL, thinks. |
Purpose
Linked issue: close #296
Tests
KvSnapshotITCase#testKvSnapshotAndDelete
API and Format
Documentation