mattisonchao commented on code in PR #19844:
URL: https://github.com/apache/pulsar/pull/19844#discussion_r1139139321
##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/coordination/impl/ResourceLockImpl.java:
##########
@@ -74,22 +74,16 @@ public synchronized T getValue() {
public synchronized CompletableFuture<Void> updateValue(T newValue) {
// If there is an operation in progress, we're going to let it
complete before attempting to
// update the value
- if (pendingOperationFuture.isDone()) {
- pendingOperationFuture = CompletableFuture.completedFuture(null);
- }
-
- pendingOperationFuture = pendingOperationFuture.thenCompose(v -> {
- synchronized (ResourceLockImpl.this) {
- if (state != State.Valid) {
- return CompletableFuture.failedFuture(
- new IllegalStateException("Lock was not in valid
state: " + state));
- }
-
- return acquire(newValue);
- }
- });
-
- return pendingOperationFuture;
+ return pendingOperationFuture =
pendingOperationFuture.exceptionally(ex -> null) // ignore all the exception
Review Comment:
>I don't think we should ignore the exception here. If the pending
revalidation fails, we are not the owner of the lock anymore and we shouldn't
be updating the lock (which will anyway fail, because the version has changed).
Since `pendingOperationFuture ` is constantly updated by
`silentRevalidateOnce`, that method is ensured the state will be released if we
get a `LockBusy` or `BadVersion` exception. Therefore, in that case. This
method will consistently return `IllegalState` instead of many different
exceptions for the caller.
I am not sure if you can accept this way. If you don't think so. I can
revert this part of the changes.
--
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]