Skip to content

feat(engine): Add property for skipping locked jobs in the job executor query [#264] - #326

Merged
javahippie merged 14 commits into
mainfrom
feature/add-configuration-for-skipping-locked-rows
Aug 19, 2026
Merged

javahippie merged 14 commits into
mainfrom
feature/add-configuration-for-skipping-locked-rows

Conversation

@javahippie

@javahippie javahippie commented Dec 7, 2024 •

Copy link
Copy Markdown
Contributor

Preview Feature for the next Milestone release, not to be a part of a final release, yet.

Fixes #264

@javahippie
javahippie marked this pull request as draft December 7, 2024 21:46
@sonarqubecloud

sonarqubecloud Bot commented Dec 7, 2024

Copy link
Copy Markdown

@javahippie

Copy link
Copy Markdown
Contributor Author

@kthoms

kthoms commented Dec 17, 2024

Copy link
Copy Markdown
Contributor

I'm missing a test case, that at least checks that the SQL is containing FOR UPDATE SKIP LOCKED. Since h2 supports it maybe even an integration test with the feature enabled.

@javahippie

Copy link
Copy Markdown
Contributor Author

You're right and this is planned. This is still a draft and WIP

@javahippie
javahippie force-pushed the feature/add-configuration-for-skipping-locked-rows branch from 4eed1f9 to e5afa0e Compare February 11, 2025 22:36
@sonarqubecloud

Copy link
Copy Markdown

@kthoms kthoms added this to the 1.x-backlog milestone Apr 7, 2025
@kthoms

kthoms commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

@javahippie This could be something for version 1.1? If so, assign the milestone. Branch main is for version 1.1 already and people could start testing.

@javahippie
javahippie force-pushed the feature/add-configuration-for-skipping-locked-rows branch from e5afa0e to 2126a54 Compare November 6, 2025 15:19
@javahippie javahippie modified the milestones: 1.x-backlog, 1.1.0 Nov 6, 2025
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2025

Copy link
Copy Markdown

@javahippie
javahippie force-pushed the feature/add-configuration-for-skipping-locked-rows branch from 2126a54 to bddff30 Compare November 15, 2025 07:24
@javahippie
javahippie force-pushed the feature/add-configuration-for-skipping-locked-rows branch from 3d2993a to 8866dc0 Compare November 26, 2025 13:18
@andreybpanfilov

Copy link
Copy Markdown

We are also sporadically facing with issues described in Job-execution-rejected, unfortunately, I'm afraid this approach won't work as expected. The are two main reasons:

  1. FOR UPDATE SKIP LOCKED feature is extremely "naughty", and it's behaviour depends on both DB engine and execution plan, please check for example:
  2. JobManager must not acquire exclusive tasks which are acquired or being executed by another instances of JobManager, in turn this means if you want JobManager to be capable to run AcquireJobsCmd command in parallel, you need also to recheck what tasks have been acquired by competing instances, and somehow do not consider or remove exclusive duplicates from execution queue (yes, original camunda code seems to be broken from this perspective) - I believe serial execution of AcquireJobsCmd would perform much better (and simpler)

@github-actions

github-actions Bot commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Hey @andreybpanfilov! 🎉

Thanks for joining the discussion and leaving your first comment here. 💬
We’re glad to have you on board!

👉 Just a quick reminder to check out our Contributing Guidelines and the Code of Conduct so we can keep the collaboration smooth and welcoming for everyone.

We appreciate your input and look forward to more of your contributions. 🚀

@kthoms kthoms modified the milestones: 1.1.0, 2.0.0 Feb 24, 2026
@javahippie

Copy link
Copy Markdown
Contributor Author

Hi, @andreybpanfilov, thanks for your comments, I really appreciate your insights!

Your remarks make a lot of sense – this feature is finicky and can find edge cases which might not behave the way we like. I think your thoughts about serial execution of the AcquireJobsCmd. I will keep exploring if the FOR UPDATE SKIP LOCKED approach can be built in a robust way, but I'd also like to evaluate your proposal. I promise you that this feature won't be rushed, would at most(!) be an opt-in feature users need to actively enable and that we will scrap this idea if during testing we find out that it won't work.

@sonarqubecloud

sonarqubecloud Bot commented Mar 6, 2026

Copy link
Copy Markdown

@cachescrubber cachescrubber removed this from the 2.1.0 milestone Apr 24, 2026
@github-actions github-actions Bot added lang:java Pull requests that update Java code scope:core-api Changes to the core API: engine, dmn-engine, feel-engine, REST API, OpenAPI scope:spring-boot Changes to the Spring Boot starter. scope:tests Changes affecting only test code labels Jun 22, 2026
@javahippie

Copy link
Copy Markdown
Contributor Author

@kthoms making progress on this. Queries, Indexes seem to be robust and I think I managed to navigate around all the caveats of skip locked ... for every vendor so far (minor verifications for Oracle, because Rownum is ... well, how it is).

One question arises: You can globally configure the job executor to work by priority first, not by due date. I have never seen this flag activated, and I think very few people use this.

For the locking to work properly (and not too broad) on MySQL and MariaDB, I am adding a new index. This index does not work, if the job executor works by priority. Without an index, concurrent nodes reading from the table could lock too many entries, leading for some of the nodes to possibly get empty results and run a job executor cycle without doing anything. There are now three options:

Document that combining the skip locked behavior and priority ordering does not give you a performance boost on MySQL and MariaDB (weird, concerning for readers)
Adding a proper index, so that the Job Executor can also properly lock for priority ordering. Might impact write performance, needs a benchmark, I believe
Document that users preferring priority ordering should create the missing index themselves. In that case, the impact on anybody else is avoided, but they can optimize the engine for their preferences

It's too late in the evening for me to have a preference here, would be happy about a short discussion in the upcoming days

@javahippie

Copy link
Copy Markdown
Contributor Author

Ran the integration tests. Same flakey tests failed on multiple vendors (I think they were introduced when Thread.sleep() was replaced with awaitility. Will create an issue and fix it in a different PR.

What's now missing: Agreement on the behavior and possibly some configuration guards. If we want preview features, this would be a prime candidate

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@javahippie
javahippie marked this pull request as ready for review August 19, 2026 11:14
@kthoms kthoms added the noteworthy Should be documented in the release notes label Aug 19, 2026
@javahippie
javahippie merged commit 189981b into main Aug 19, 2026
5 checks passed
@sonarqubecloud

Copy link
Copy Markdown

@kthoms
kthoms deleted the feature/add-configuration-for-skipping-locked-rows branch October 16, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang:java Pull requests that update Java code noteworthy Should be documented in the release notes scope:core-api Changes to the core API: engine, dmn-engine, feel-engine, REST API, OpenAPI scope:spring-boot Changes to the Spring Boot starter. scope:tests Changes affecting only test code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a configuration to skip locked rows in the select statement for the job executor

4 participants