This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new ad450e59af [#9085] fix(core): enforce minimum jobStatusKeepTimeInMs
instead of throwing IllegalArgumentException. (#9102)
ad450e59af is described below
commit ad450e59af68bd4447ecbd18a99e1b334df3aeec
Author: Harsh Mehta <[email protected]>
AuthorDate: Thu Nov 13 23:00:26 2025 +0530
[#9085] fix(core): enforce minimum jobStatusKeepTimeInMs instead of
throwing IllegalArgumentException. (#9102)
# Fixed #9085
## Summary
This PR updates the initialization logic in `LocalJobExecutor` to ensure
that `jobStatusKeepTimeInMs` is never set below a safe minimum
threshold.
Previously, users could configure `JOB_STATUS_KEEP_TIME_MS` to values
below 10 ms, which was unsupported and could lead to
IllegalArgumentException.
With this change, any value below **10 ms** will now be **clamped to 10
ms**.
Values **≥ 10 ms** remain unchanged.
## Testing
- **Unit tests:** Added test verifying that values below 10 ms are
clamped correctly.
- **Existing tests:** Unaffected and continue to pass (values ≥ 10 ms
behave as before).
- **Manual verification:**
- Provided value `1 ms` → clamped to `10 ms`
- Provided value `11 ms` → remains `11 ms`
---
**Example Behavior:**
| Input (ms) | Result (ms) |
|-------------|-------------|
| 1 | 10 |
| 11 | 11 |
---
✅ **Result:** Safer initialization logic and consistent minimum timing
behavior in `LocalJobExecutor`.
---------
Signed-off-by: Harsh Mehta <[email protected]>
---
.../gravitino/job/local/LocalJobExecutor.java | 1 +
.../gravitino/job/local/TestLocalJobExecutor.java | 27 ++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git
a/core/src/main/java/org/apache/gravitino/job/local/LocalJobExecutor.java
b/core/src/main/java/org/apache/gravitino/job/local/LocalJobExecutor.java
index 4b1af0e4ec..f3b6e5d631 100644
--- a/core/src/main/java/org/apache/gravitino/job/local/LocalJobExecutor.java
+++ b/core/src/main/java/org/apache/gravitino/job/local/LocalJobExecutor.java
@@ -133,6 +133,7 @@ public class LocalJobExecutor implements JobExecutor {
"Job status keep time must be greater than 0, but got: %s",
jobStatusKeepTimeInMs);
+ this.jobStatusKeepTimeInMs = Math.max(jobStatusKeepTimeInMs, 10);
long jobStatusCleanupIntervalInMs = jobStatusKeepTimeInMs / 10;
this.jobStatusCleanupExecutor =
Executors.newSingleThreadScheduledExecutor(
diff --git
a/core/src/test/java/org/apache/gravitino/job/local/TestLocalJobExecutor.java
b/core/src/test/java/org/apache/gravitino/job/local/TestLocalJobExecutor.java
index 6c2dab5ad1..4f4100a3e3 100644
---
a/core/src/test/java/org/apache/gravitino/job/local/TestLocalJobExecutor.java
+++
b/core/src/test/java/org/apache/gravitino/job/local/TestLocalJobExecutor.java
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Field;
import java.net.URL;
import java.nio.file.Files;
import java.util.Collections;
@@ -226,4 +227,30 @@ public class TestLocalJobExecutor {
Assertions.assertDoesNotThrow(() -> jobExecutor.cancelJob(failJobId));
Assertions.assertEquals(JobHandle.Status.FAILED,
jobExecutor.getJobStatus(failJobId));
}
+
+ @Test
+ public void testInitializeWithSmallJobStatusKeepTimeIsClampedToMinimum()
+ throws NoSuchFieldException, IllegalAccessException {
+ LocalJobExecutor exec = new LocalJobExecutor();
+
+
exec.initialize(ImmutableMap.of(LocalJobExecutorConfigs.JOB_STATUS_KEEP_TIME_MS,
"1"));
+
+ Field field =
LocalJobExecutor.class.getDeclaredField("jobStatusKeepTimeInMs");
+ field.setAccessible(true);
+ long actualValue = (long) field.get(exec);
+ Assertions.assertEquals(10L, actualValue);
+ }
+
+ @Test
+ public void TestInitializeWithLargeJobStatusKeepTimeIsClampedToSameValue()
+ throws NoSuchFieldException, IllegalAccessException {
+ LocalJobExecutor exec = new LocalJobExecutor();
+
+
exec.initialize(ImmutableMap.of(LocalJobExecutorConfigs.JOB_STATUS_KEEP_TIME_MS,
"11"));
+
+ Field field =
LocalJobExecutor.class.getDeclaredField("jobStatusKeepTimeInMs");
+ field.setAccessible(true);
+ long actualValue = (long) field.get(exec);
+ Assertions.assertEquals(11L, actualValue);
+ }
}