Skip to content

Commit

Permalink
[bugfix]thread pool resource leak for 2.1 apache#36990 (apache#37247)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwenchi authored Jul 4, 2024
1 parent bf3ea18 commit 5f3e1e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -315,6 +316,7 @@ public void doCommit() {
throw t;
} finally {
hmsCommitter.runClearPathsForFinish();
hmsCommitter.shutdownExecutorService();
}
}

Expand Down Expand Up @@ -1110,7 +1112,7 @@ class HmsCommitter {

// update statistics for unPartitioned table or existed partition
private final List<UpdateStatisticsTask> updateStatisticsTasks = new ArrayList<>();
Executor updateStatisticsExecutor = Executors.newFixedThreadPool(16);
ExecutorService updateStatisticsExecutor = Executors.newFixedThreadPool(16);

// add new partition
private final AddPartitionsTask addPartitionsTask = new AddPartitionsTask();
Expand Down Expand Up @@ -1529,6 +1531,10 @@ public void rollback() {
MoreFutures.getFutureValue(future, RuntimeException.class);
}
}

public void shutdownExecutorService() {
updateStatisticsExecutor.shutdownNow();
}
}

public Status wrapperRenameDirWithProfileSummary(String origFilePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ public void updateTableStatistics(
newTable.setParameters(newParams);
client.client.alter_table(dbName, tableName, newTable);
} catch (Exception e) {
throw new RuntimeException("failed to update table statistics for " + dbName + "." + tableName);
throw new RuntimeException("failed to update table statistics for " + dbName + "." + tableName, e);
}
}

Expand Down Expand Up @@ -710,7 +710,7 @@ public void updatePartitionStatistics(
modifiedPartition.setParameters(newParams);
client.client.alter_partition(dbName, tableName, modifiedPartition);
} catch (Exception e) {
throw new RuntimeException("failed to update table statistics for " + dbName + "." + tableName);
throw new RuntimeException("failed to update table statistics for " + dbName + "." + tableName, e);
}
}

Expand All @@ -731,7 +731,7 @@ public void dropPartition(String dbName, String tableName, List<String> partitio
try (ThriftHMSClient client = getClient()) {
client.client.dropPartition(dbName, tableName, partitionValues, deleteData);
} catch (Exception e) {
throw new RuntimeException("failed to drop partition for " + dbName + "." + tableName);
throw new RuntimeException("failed to drop partition for " + dbName + "." + tableName, e);
}
}
}

0 comments on commit 5f3e1e4

Please sign in to comment.