From ee0a82a6c87f996e5c14fb6064f301bc72dab856 Mon Sep 17 00:00:00 2001 From: gabrywu Date: Sat, 25 Nov 2023 12:34:59 +0800 Subject: [PATCH 1/6] shutdown scheduler --- .../main/java/org/apache/iceberg/util/LockManagers.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/main/java/org/apache/iceberg/util/LockManagers.java b/core/src/main/java/org/apache/iceberg/util/LockManagers.java index ed141bdf7ba1..a198071c93d4 100644 --- a/core/src/main/java/org/apache/iceberg/util/LockManagers.java +++ b/core/src/main/java/org/apache/iceberg/util/LockManagers.java @@ -153,6 +153,14 @@ public void initialize(Map properties) { CatalogProperties.LOCK_HEARTBEAT_THREADS, CatalogProperties.LOCK_HEARTBEAT_THREADS_DEFAULT); } + + @Override + public void close() { + if (scheduler != null) { + scheduler.shutdownNow(); + scheduler = null; + } + } } /** @@ -263,6 +271,7 @@ public void close() { HEARTBEATS.values().forEach(future -> future.cancel(false)); HEARTBEATS.clear(); LOCKS.clear(); + super.close(); } } From 254fad0fad4a16da65d511140ec3633c7e92ff19 Mon Sep 17 00:00:00 2001 From: gabrywu Date: Fri, 15 Dec 2023 10:23:50 +0800 Subject: [PATCH 2/6] fix ci error --- core/src/main/java/org/apache/iceberg/util/LockManagers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/iceberg/util/LockManagers.java b/core/src/main/java/org/apache/iceberg/util/LockManagers.java index a198071c93d4..45b5c09bde6f 100644 --- a/core/src/main/java/org/apache/iceberg/util/LockManagers.java +++ b/core/src/main/java/org/apache/iceberg/util/LockManagers.java @@ -155,7 +155,7 @@ public void initialize(Map properties) { } @Override - public void close() { + public void close() throws Exception { if (scheduler != null) { scheduler.shutdownNow(); scheduler = null; From 516809ead435890e79e3c76b8192564dd869ba1b Mon Sep 17 00:00:00 2001 From: gabrywu Date: Mon, 18 Dec 2023 13:47:42 +0800 Subject: [PATCH 3/6] fix ci error --- core/src/main/java/org/apache/iceberg/util/LockManagers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/iceberg/util/LockManagers.java b/core/src/main/java/org/apache/iceberg/util/LockManagers.java index 45b5c09bde6f..ef55f6049042 100644 --- a/core/src/main/java/org/apache/iceberg/util/LockManagers.java +++ b/core/src/main/java/org/apache/iceberg/util/LockManagers.java @@ -267,7 +267,7 @@ public boolean release(String entityId, String ownerId) { } @Override - public void close() { + public void close() throws Exception { HEARTBEATS.values().forEach(future -> future.cancel(false)); HEARTBEATS.clear(); LOCKS.clear(); From f374e16cd8ee49d7dc43b7c604516773aac19336 Mon Sep 17 00:00:00 2001 From: gabrywu Date: Mon, 18 Dec 2023 14:00:28 +0800 Subject: [PATCH 4/6] fix ci error --- .../java/org/apache/iceberg/util/TestInMemoryLockManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/org/apache/iceberg/util/TestInMemoryLockManager.java b/core/src/test/java/org/apache/iceberg/util/TestInMemoryLockManager.java index 48fc4a2cb3c1..69c92bfd004b 100644 --- a/core/src/test/java/org/apache/iceberg/util/TestInMemoryLockManager.java +++ b/core/src/test/java/org/apache/iceberg/util/TestInMemoryLockManager.java @@ -51,7 +51,7 @@ public void before() { } @After - public void after() { + public void after() throws Exception { lockManager.close(); } From b0845b982f11215165ee35f5fea60d5994350e19 Mon Sep 17 00:00:00 2001 From: Eduard Tudenhoefner Date: Mon, 18 Dec 2023 17:53:51 +0100 Subject: [PATCH 5/6] Update core/src/main/java/org/apache/iceberg/util/LockManagers.java --- .../main/java/org/apache/iceberg/util/LockManagers.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/iceberg/util/LockManagers.java b/core/src/main/java/org/apache/iceberg/util/LockManagers.java index 99d8fad1fbc0..c4220fe08230 100644 --- a/core/src/main/java/org/apache/iceberg/util/LockManagers.java +++ b/core/src/main/java/org/apache/iceberg/util/LockManagers.java @@ -158,7 +158,13 @@ public void initialize(Map properties) { @Override public void close() throws Exception { if (scheduler != null) { - scheduler.shutdownNow(); + List tasks = scheduler.shutdownNow(); + tasks.forEach( + task -> { + if (task instanceof Future) { + ((Future) task).cancel(true); + } + }); scheduler = null; } } From 4bdb5f6a06d17e1275be596b200b8147c08593a4 Mon Sep 17 00:00:00 2001 From: Eduard Tudenhoefner Date: Mon, 18 Dec 2023 17:58:57 +0100 Subject: [PATCH 6/6] imports --- core/src/main/java/org/apache/iceberg/util/LockManagers.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/org/apache/iceberg/util/LockManagers.java b/core/src/main/java/org/apache/iceberg/util/LockManagers.java index c4220fe08230..96622cb57f83 100644 --- a/core/src/main/java/org/apache/iceberg/util/LockManagers.java +++ b/core/src/main/java/org/apache/iceberg/util/LockManagers.java @@ -18,9 +18,11 @@ */ package org.apache.iceberg.util; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor;