Skip to content

CAMEL-23294: fix orphan lock race in JDBC idempotent repository (4.18.x)#22518

Merged
davsclaus merged 1 commit intoapache:camel-4.18.xfrom
Croway:CAMEL-23294-fix-orphan-lock-race-4.18.x
Apr 10, 2026
Merged

CAMEL-23294: fix orphan lock race in JDBC idempotent repository (4.18.x)#22518
davsclaus merged 1 commit intoapache:camel-4.18.xfrom
Croway:CAMEL-23294-fix-orphan-lock-race-4.18.x

Conversation

@Croway
Copy link
Copy Markdown
Contributor

@Croway Croway commented Apr 9, 2026

Summary

Claude Code on behalf of Federico Mariani

Backport of #22515 to camel-4.18.x.

Fixes a race condition in JdbcOrphanLockAwareIdempotentRepository where multiple instances can simultaneously acquire the same orphan lock, causing duplicate file processing with readLock=idempotent.

  • add() now checks insert()'s return value
  • insert() uses conditional UPDATE ... WHERE createdAt < ? for orphan recovery

Test plan

  • New concurrency test added
  • All existing idempotent repository tests pass
  • Clean cherry-pick from main

When multiple instances concurrently recover the same orphan lock,
both succeed because add() ignores insert()'s return value and
insert() updates the timestamp unconditionally.

Fix:
- add() now checks insert()'s return value (0 = not acquired)
- insert() uses conditional UPDATE (WHERE createdAt < ?) for orphan
  recovery so only one instance can claim an orphan lock
@davsclaus davsclaus merged commit 7b819f1 into apache:camel-4.18.x Apr 10, 2026
3 checks passed
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.

3 participants