Skip to content

Commit a9e5dc3

Browse files
LiebingYuLiebing
authored andcommitted
[server] Use background mode for delete partition assignment in zk
1 parent dbbfc79 commit a9e5dc3

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

fluss-server/src/main/java/org/apache/fluss/server/zk/ZooKeeperClient.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,27 @@ public void deleteTableAssignment(long tableId) throws Exception {
222222

223223
public void deletePartitionAssignment(long partitionId) throws Exception {
224224
String path = PartitionIdZNode.path(partitionId);
225-
zkClient.delete().deletingChildrenIfNeeded().forPath(path);
226-
LOG.info("Deleted table assignment for partition id {}.", partitionId);
225+
// delete partition assignment ZNode will recursively delete all the children which may
226+
// block
227+
// for a long time, so we use background mode here.
228+
zkClient.delete()
229+
.deletingChildrenIfNeeded()
230+
.inBackground(
231+
(client, event) -> {
232+
if (event.getResultCode() == KeeperException.Code.OK.intValue()) {
233+
LOG.info(
234+
"Deleted table assignment for partition id {}.",
235+
partitionId);
236+
} else {
237+
KeeperException.Code code =
238+
KeeperException.Code.get(event.getResultCode());
239+
LOG.error(
240+
"Failed to delete partition assignment for partition id {}. Error message: {}",
241+
partitionId,
242+
code.toString());
243+
}
244+
})
245+
.forPath(path);
227246
}
228247

229248
// --------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)