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

fix(job-thread): add synchronized block to avoid repeat trigger job #3506

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oleolema
Copy link

@oleolema oleolema commented Jul 16, 2024

Add synchronized block around triggerLogIdSet check and addition to ensure thread-safety and prevent repeated job triggers. This update modifies the JobThread class to handle concurrent access to triggerLogIdSet properly.

What kind of change does this PR introduce? (check at least one)

  • Bugfix

The description of the PR:
triggerLogIdSet.contains 和 triggerLogIdSet.add 两个操作之间可能存在竞态条件。也就是说,如果在检查 triggerLogIdSet.contains 之后,但在 triggerLogIdSet.add 之前,另一个线程插入了相同的 logId,那么 logId 就会被重复添加。这种情况在实际中可能会出现问题。
image

Other information:

Add synchronized block around triggerLogIdSet check and addition to ensure thread-safety
and prevent repeated job triggers. This update modifies the JobThread class to handle
concurrent access to triggerLogIdSet properly.
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

Successfully merging this pull request may close these issues.

1 participant