colinwerner opened a new pull request, #2664: URL: https://github.com/apache/activemq/pull/2664
Closes #2663 `LeaseDatabaseLocker` uses `lockAcquireSleepInterval` both as the lease duration and as the wait between acquire attempts. A lease that is long enough to be safe also makes a waiting broker poll slowly, so a lease that has expired or been released is picked up up to a full lease duration late. This adds an optional `lockAcquireRetryInterval` (`<lease-database-locker lockAcquireRetryInterval="..."/>`): - it sets only the wait between acquire attempts in `doStart()`; `lockAcquireSleepInterval` remains the lease duration in `doStart()` and `keepAlive()`; - unset or `<= 0` (the default) uses `lockAcquireSleepInterval`, so existing configurations are unchanged; - logs a warning if it is longer than the lease; - the retry debug log reports the interval in use. The attribute appears in the generated `activemq.xsd` under `lease-database-locker`. Commits: 1. **Re-enable `LeaseDatabaseLockerTest`.** The class was `@Ignore`d during the jakarta migration (AMQ-9239), so new tests there would not run. The Derby tests passed as-is. The three time-offset tests failed only because the mocked `Statements.getCurrentDateTime()` returned null, which Mockito's `anyString()` does not match. Stubbing it fixes them. 2. **Add `lockAcquireRetryInterval`.** 3. **Report the keep-alive period as `renew` in `toString()`.** `toString()` printed `lockAcquireSleepInterval` for both `duration` and `renew`, but the lease is renewed every `lockKeepAlivePeriod`. It's included here because this PR is about separating the locker's timings, and `toString()` is where they are read when tuning failover. With this change it reports all three correctly (`duration`, `renew`, `retry`). It's a separate commit so it can be dropped if preferred. Tests (`LeaseDatabaseLockerTest`, embedded Derby): - `testReleasedLeaseAcquiredWithinLockAcquireRetryInterval`: with a 10 s lease and a 250 ms retry interval, a waiting locker acquires a released lease in well under 2.5 s (about 50 ms locally; about 9.8 s before this change), and the acquired lease still runs for the full lease duration. - `testDefaultLockAcquireRetryIntervalIsLockAcquireSleepInterval`: with the property unset, a released lease is picked up on the next `lockAcquireSleepInterval` poll, as before. - `testToStringReportsLeaseTimings`: `toString()` reports the lease duration, the keep-alive period and the retry interval. ``` mvn -pl activemq-jdbc-store,activemq-unit-tests test -Dtest=LeaseDatabaseLockerTest -Dsurefire.failIfNoSpecifiedTests=false ``` Note: on current `main`, `activemq-broker` test-compile fails in `ManagementContextSslTest` (`SslContext` is abstract), which is unrelated to this change. I ran the tests above against the other modules built with `-DskipTests`. Docs: the JDBC master/slave / pluggable storage lockers page in `activemq-website` should list the new attribute; I can open a follow-up PR there. Generated with Claude Code. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information, visit: https://activemq.apache.org/contact
