Fix DynamoDbLockRepository.renew() logic

The new `TTL` must come with `+leaseDuration`
This commit is contained in:
abilan
2023-02-27 17:20:40 -05:00
parent 620f327483
commit 88cc93018e

View File

@@ -404,12 +404,16 @@ public class DynamoDbLockRepository implements InitializingBean, DisposableBean,
public boolean renew(String lock) {
awaitForActive();
if (this.heldLocks.contains(lock)) {
ValueMap valueMap =
new ValueMap()
.withNumber(":ttl", ttlEpochSeconds());
valueMap.putAll(this.ownerAttribute);
UpdateItemSpec updateItemSpec =
new UpdateItemSpec()
.withPrimaryKey(KEY_ATTR, lock)
.withUpdateExpression("SET " + TTL_ATTR + " = :ttl")
.withConditionExpression(LOCK_EXISTS_EXPRESSION)
.withValueMap(ownerWithCurrentTimeValues());
.withValueMap(valueMap);
try {
this.lockTable.updateItem(updateItemSpec);
return true;