Skip to content

[Bug] DiscardPolicy usage in JetCacheExecutor leads to silent cache refresh failures #1000

@QiuYucheng2003

Description

@QiuYucheng2003

Bug Description
The heavyIOExecutor in JetCacheExecutor is explicitly configured with ThreadPoolExecutor.DiscardPolicy.

This causes a critical issue in RefreshCache: when the thread pool is busy or full, the refresh task submitted via scheduleWithFixedDelay is silently discarded.

Root Cause Analysis:
In com.alicp.jetcache.support.JetCacheExecutor.java:
// Line 88-89
heavyIOExecutor = new ScheduledThreadPoolExecutor(
10, tf, new ThreadPoolExecutor.DiscardPolicy());

The DiscardPolicy drops the task without throwing any exception.

Impact

  1. Silent Failure: The caller (RefreshCache.addOrUpdateRefreshTask) has no way to know that the schedule failed.

  2. Stale Data: The cache key will stop refreshing. Once the TTL expires, the business layer will read stale/dirty data (or cache miss) indefinitely.

  3. No Observability: No error logs are printed, making it extremely difficult to debug in production environments.

Expected Behavior
The executor should use the default AbortPolicy (or a policy that throws exceptions). The caller (RefreshCache) should catch the RejectedExecutionException and log an error to alert that the refresh task failed to schedule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions