Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pushTimeRing在并发场景会出现任务丢失 #3388

Open
yiyuankafei opened this issue Feb 7, 2024 · 0 comments
Open

pushTimeRing在并发场景会出现任务丢失 #3388

yiyuankafei opened this issue Feb 7, 2024 · 0 comments

Comments

@yiyuankafei
Copy link

yiyuankafei commented Feb 7, 2024

Please answer some questions before submitting your issue. Thanks!

Which version of XXL-JOB do you using?

2.4.0

    private volatile static Map<Integer, List<Integer>> ringData = new ConcurrentHashMap<>();

并发情况下,会出现两个线程同时走到ringItemData == null,导致其中一个线程add的jobId被另一个线程的空List覆盖掉

    private void pushTimeRing(int ringSecond, int jobId){
        // push async ring
        List<Integer> ringItemData = ringData.get(ringSecond);
        if (ringItemData == null) {
            ringItemData = new ArrayList<Integer>();
            ringData.put(ringSecond, ringItemData);
        }
        ringItemData.add(jobId);

        logger.debug(">>>>>>>>>>> xxl-job, schedule push time-ring : " + ringSecond + " = " + Arrays.asList(ringItemData) );
    }

虽然目前看只有一个守护线程会调用pushTimeRing,感觉在将来扩展的时候会成为一个隐患

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant