Croway commented on PR #30162:
URL: https://github.com/apache/camel/pull/30162#issuecomment-6913196906

   Thanks @davsclaus, all four are addressed in e5d69d1aa5e3.
   
   - **[Suggestion] confirm window**: confirmed and fixed in this PR. With an 
aged lease, and the confirm held between taking the key out of the keep-alive 
set and its UPDATE, a copy on the same instance was accepted (`add()` returned 
true). `confirm()` now adds the key to a `confirming` set before it takes it 
out of `processorNameMessageIdSet`, and removes it in `finally`, after putting 
it back in the keep-alive set when the confirm failed. `queryForInt` checks 
both sets. It reads `processorNameMessageIdSet` once more after `confirming`, 
because a failed confirm can put the key back between the first two reads. The 
keep-alive still reads only `processorNameMessageIdSet`, so it still does not 
wait for the row lock of the confirm.
     `remove()` does not have this window. `delete(key)` runs the DELETE first 
and takes the key out of the keep-alive set only afterwards. By then the row is 
locked by the remove's transaction, and once that commits the key is gone, 
which is what the remove asks for.
     New tests in `JdbcOrphanLockAwareIdempotentRepositoryOutageTest`. In each, 
a `JdbcTemplate` holds node A's statement on a latch while a copy of the key 
reaches node A (no sleeps):
     - `testKeyBeingConfirmedIsStillADuplicateOnItsNodeAfterAnOutage` holds the 
confirm's UPDATE. It fails on c3619e18d0ac (`add()` returns true) and passes 
now.
     - `testKeyBeingRemovedIsStillADuplicateOnItsNodeUntilItsDelete` holds the 
remove's DELETE. It passes either way and makes sure the DELETE stays ahead of 
taking the key out of the keep-alive set.
   - **[Nit] docs**: the paragraph now says the WARN is logged when the 
instance holds keys and their locks have not been refreshed for longer than 
`lockMaxAgeMillis` (component doc and catalog copy).
   - **[Nit] description**: fixed. For a held key only the SELECT is skipped; 
`add()` and `contains()` still run in their transaction.
   - **[Nit] recordingLogger**: moved to `RecordingLogger`, a package-private 
test helper used by the confirm and outage tests.
   
   _Claude Code on behalf of Croway_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to