wzx140 commented on code in PR #3476:
URL: https://github.com/apache/fluss/pull/3476#discussion_r3402185248
##########
fluss-server/src/main/java/org/apache/fluss/server/zk/data/lake/LakeTableHelper.java:
##########
@@ -79,6 +79,24 @@ public void registerLakeTableSnapshotV2(
registerLakeTableSnapshotV2(tableId, lakeSnapshotMetadata, null);
}
+ /** Clears the committed lake table progress for the given table. */
+ public void clearLakeTableProgress(long tableId) throws Exception {
+ Optional<LakeTable> optLakeTable = zkClient.getLakeTable(tableId);
+ if (!optLakeTable.isPresent()) {
+ return;
+ }
+
+ zkClient.deleteLakeTable(tableId);
+ LakeTable lakeTable = optLakeTable.get();
+ List<LakeTable.LakeSnapshotMetadata> lakeSnapshotMetadatas =
+ lakeTable.getLakeSnapshotMetadatas();
+ if (lakeSnapshotMetadatas != null) {
+ for (LakeTable.LakeSnapshotMetadata lakeSnapshotMetadata :
lakeSnapshotMetadatas) {
+ lakeSnapshotMetadata.discard();
+ }
+ }
+ }
Review Comment:
Fixed. `clearLakeTableProgress` now discards the snapshot metadata first and
deletes the ZK lake progress node after cleanup succeeds, so an IO failure
during discard will not lose the progress reference.
##########
fluss-server/src/main/java/org/apache/fluss/server/zk/ZooKeeperClient.java:
##########
@@ -1365,6 +1365,16 @@ public Optional<LakeTable> getLakeTable(long tableId)
throws Exception {
return getOrEmpty(zkPath).map(LakeTableZNode::decode);
}
+ /** Deletes the {@link LakeTable} for the given table ID if it exists. */
+ public void deleteLakeTable(long tableId) throws Exception {
+ String zkPath = LakeTableZNode.path(tableId);
+ try {
+ zkClient.delete().forPath(zkPath);
+ } catch (KeeperException.NoNodeException ignored) {
+ // Ignore if the lake table progress has not been committed yet.
+ }
+ }
Review Comment:
Fixed. `deleteLakeTable` now uses `deletingChildrenIfNeeded().forPath(...)`
and still ignores `NoNodeException`, so the cleanup is robust if the lake-table
znode gains children later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]