-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-3272: Support lease renewal for distributed locks #3317
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, run gradlew check
locally before pushing commits:
[ant:checkstyle] [ERROR] /home/travis/build/spring-projects/spring-integration/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java:289:33: '}' at column 5 should be alone on a line. [RightCurly]
[ant:checkstyle] [ERROR] /home/travis/build/spring-projects/spring-integration/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java:291:33: '}' at column 5 should be alone on a line. [RightCurly]
[ant:checkstyle] [ERROR] /home/travis/build/spring-projects/spring-integration/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/RenewableLockRegistry.java:21:1: Wrong order for 'java.util.concurrent.locks.Lock' import. [ImportOrder]
Thanks.
I wonder also what do you think about other LockRegistry
implementations...
544924e
to
a8b5d54
Compare
@artembilan I'm sorry for the code style committed... For the other implementations I can merge my new |
You are right. I'll give you some feedback to your code a bit later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all I thought we would need to introduce a DistributedLock
abstraction and have that renew
over there, but then I have figured that we may not have access to lock
object in some places. More over it turns out that not all distributed locks (Hazelcast, Zookeer, Geode etc) give us access to some renewal hook.
Therefore it really should be a particular LockRegistry
contract like you did with this RenewableLockRegistry
.
@garyrussell , WDYT?
We need to add some docs for this new feature in the jdbc.adoc
and a note with the link in the whats-new.adoc
.
...tegration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
Outdated
Show resolved
Hide resolved
...tion-jdbc/src/main/java/org/springframework/integration/jdbc/lock/RenewableLockRegistry.java
Outdated
Show resolved
Hide resolved
...tion-jdbc/src/main/java/org/springframework/integration/jdbc/lock/RenewableLockRegistry.java
Outdated
Show resolved
Hide resolved
...tegration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
Show resolved
Hide resolved
...tegration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
Outdated
Show resolved
Hide resolved
|
a8b5d54
to
efffe4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to add a whats-new.adoc
not for that RenewableLockRegistry
and explain its behavior in the jdbc.adoc
at the jdbc-lock-registry
section?
When we merge this, let's consider which other LockRegistry
implementations could support renewing as well.
Thanks
...tegration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to take a look why JDBC lock tests are failing:
JdbcLockRegistryDifferentClientTests > testRenewLock FAILED
java.lang.IllegalArgumentException at JdbcLockRegistryDifferentClientTests.java:377
JdbcLockRegistryTests > testLockRenewLockNotOwned FAILED
org.opentest4j.AssertionFailedError at JdbcLockRegistryTests.java:283
Caused by: java.lang.IllegalArgumentException at JdbcLockRegistryTests.java:283
JdbcLockRegistryTests > testLockRenew FAILED
java.lang.IllegalArgumentException at JdbcLockRegistryTests.java:276
?
Looks like some of them are new yours...
efffe4b
to
d4786ff
Compare
There are 3 others test failed now.. :(
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple nit-picks.
Thanks
public void testLockRenewLockNotOwned() { | ||
this.registry.obtain("foo"); | ||
|
||
Assertions.assertThrows(IllegalMonitorStateException.class, () -> registry.renewLock("foo")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer AssertJ assertions instead: assertThatExceptionOfType()
Starting with version 5.4, the `RenewableLockRegistry` interface has been introduced and added to `JdbcLockRegistry`. | ||
The `renewLock()` method must be called during locked process in case of the locked process would be longer than time to live of the lock. | ||
So the time to live can be highly reduce and deployments can retake a lost lock quickly. | ||
NB. The lock renewal can be done only if the lock is held by the current thread, so the locked process has to be executed in another thread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what is this NB
about.
Can we have a more official language in the docs, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB (latin Nota Bene - "note well") is commonly used in real (British) English - it is not common in the USA.
Use AsciiDoctor NOTE:
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right! Didn't think through. This sentence is really NOTE:
.
Thank you, Gary!
OK. So, I'm pulling this locally and fixing the latest simple concerns on merge.
Lock TTL renewal feature for JDBC
issue #3272
I retrieved some lines from stefanvassilev@cb5d968