You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mm...@apache.org on 2021/01/21 18:23:58 UTC

[accumulo] branch main updated: Add cast checks to compaction cancel method. Fixes #1875 (#1876)

This is an automated email from the ASF dual-hosted git repository.

mmiller pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 06251db  Add cast checks to compaction cancel method. Fixes #1875 (#1876)
06251db is described below

commit 06251dba99a8655c0db6786866447a6995976eb2
Author: Mike Miller <mm...@apache.org>
AuthorDate: Thu Jan 21 13:22:21 2021 -0500

    Add cast checks to compaction cancel method. Fixes #1875 (#1876)
---
 .../accumulo/tserver/compactions/CompactionExecutor.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/compactions/CompactionExecutor.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/compactions/CompactionExecutor.java
index a743509..21cf147 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/compactions/CompactionExecutor.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/compactions/CompactionExecutor.java
@@ -117,7 +117,19 @@ public class CompactionExecutor {
         // Occasionally clean the queue of canceled tasks that have hung around because of their low
         // priority. This runs periodically, instead of every time something is canceled, to avoid
         // hurting performance.
-        queue.removeIf(runnable -> ((CompactionTask) runnable).getStatus() == Status.CANCELED);
+        queue.removeIf(runnable -> {
+          CompactionTask compactionTask;
+          if (runnable instanceof TraceRunnable) {
+            runnable = ((TraceRunnable) runnable).getRunnable();
+          }
+          if (runnable instanceof CompactionTask) {
+            compactionTask = (CompactionTask) runnable;
+          } else {
+            throw new IllegalArgumentException(
+                "Unknown runnable type " + runnable.getClass().getName());
+          }
+          return compactionTask.getStatus() == Status.CANCELED;
+        });
       }
 
       return canceled;