This is an automated email from the ASF dual-hosted git repository.
xuba pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git
The following commit(s) were added to refs/heads/master by this push:
new 31b064cc0 Optimize the performance of optimizer pollTask (#3583)
31b064cc0 is described below
commit 31b064cc0ccb6eaaaf98355c7ed95b913b9e06cb
Author: Darcy <[email protected]>
AuthorDate: Thu May 29 22:17:19 2025 +0800
Optimize the performance of optimizer pollTask (#3583)
Optimize the implementation of the TableOptimizingProcess.poll() function
to avoid waiting for locks and return immediately if the lock cannot be
acquired.
Co-authored-by: Xu Bai <[email protected]>
---
.../apache/amoro/server/optimizing/OptimizingQueue.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git
a/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/OptimizingQueue.java
b/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/OptimizingQueue.java
index 06161ea87..d6e1a2a73 100644
---
a/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/OptimizingQueue.java
+++
b/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/OptimizingQueue.java
@@ -399,14 +399,16 @@ public class OptimizingQueue extends PersistentBase {
private boolean hasCommitted = false;
public TaskRuntime<?> poll() {
- lock.lock();
- try {
- return status != ProcessStatus.KILLED && status != ProcessStatus.FAILED
- ? taskQueue.poll()
- : null;
- } finally {
- lock.unlock();
+ if (lock.tryLock()) {
+ try {
+ return status != ProcessStatus.KILLED && status !=
ProcessStatus.FAILED
+ ? taskQueue.poll()
+ : null;
+ } finally {
+ lock.unlock();
+ }
}
+ return null;
}
public TableOptimizingProcess(