This is an automated email from the ASF dual-hosted git repository.
hulee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new 5335b6339 Fixed size history for Scheduled Workflow tasks (#2036)
5335b6339 is described below
commit 5335b6339a64760c9e1442120c12c6297505ad5d
Author: Komal Desai <[email protected]>
AuthorDate: Sat Apr 16 15:31:19 2022 -0700
Fixed size history for Scheduled Workflow tasks (#2036)
Once we execute scheduled workflow task, we append entry to history.
Each entry is of the format "<taskname>-<timestamp>"
But we never purged old entries.
This will result in hitting size limit of Znode.
Introducing fixed size history of 20 and purge all the previous entries.
---
.../src/main/java/org/apache/helix/task/WorkflowContext.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git
a/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java
b/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java
index 701e36ec7..7979397c0 100644
--- a/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java
+++ b/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java
@@ -57,6 +57,9 @@ public class WorkflowContext extends HelixProperty {
// Otherwise, the context will not be written to ZK by the controller.
private boolean isModified;
+ // Have fixed size history of Scheduled Workflow Tasks
+ private final static int SCHEDULED_WORKFLOW_HISTORY_SIZE = 20;
+
public WorkflowContext(ZNRecord record) {
super(record);
isModified = false;
@@ -234,6 +237,10 @@ public class WorkflowContext extends HelixProperty {
scheduledWorkflows);
}
if (!scheduledWorkflows.contains(workflow)) {
+ // This while loop is to cleanup existing scheduled workflows
+ while (scheduledWorkflows.size() >= SCHEDULED_WORKFLOW_HISTORY_SIZE) {
+ scheduledWorkflows.remove(0);
+ }
scheduledWorkflows.add(workflow);
markWorkflowContextAsModified();
}