315157973 commented on a change in pull request #9900:
URL: https://github.com/apache/pulsar/pull/9900#discussion_r594372747
##########
File path:
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java
##########
@@ -97,6 +98,28 @@ public void set(String path, Function<T, T> modifyFunction)
throws MetadataStore
}
}
+ public void set(String path, OrderedExecutor executor, Function<T, T>
modifyFunction) throws MetadataStoreException {
+ CompletableFuture<Void> callback = new CompletableFuture<>();
+ // Use orderedExecutor to ensure that
+ // concurrent updates in each path are handled by a single thread
+ executor.executeOrdered(path, () ->
Review comment:
If roderedExecutor is not used, it will become like this:
Assuming Policies={}
t1: Thread-1 read + clone Policies, Thread-2 read + clone Policies
t2: Thread-1 modifies Policies to {a=1}, Thread-2 modifies Policies to {b=2}
t3: Thread-1 writes back Policies, Thread-2 writes back Policies
Finally Policies={b=2}, the result we expect is {a=1,b=2}
If roderedExecutor is used:
t1: Thread-1 read+clone+modify+update, Policies are {a=1}
t2: Thread-2 read+clone+modify+update, Policies are {a=1,b=2}
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]