You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/04/01 09:40:22 UTC

[GitHub] [pulsar] Jason918 commented on a change in pull request #14903: [metadata] fix MetadataStore#put may get unexcepted exception

Jason918 commented on a change in pull request #14903:
URL: https://github.com/apache/pulsar/pull/14903#discussion_r840410789



##########
File path: pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java
##########
@@ -386,7 +386,13 @@ private void internalStorePut(OpPut opPut) {
                                 put(opPut.getPath(), opPut.getData(), Optional.of(-1L)).thenAccept(
                                                 s -> future.complete(s))
                                         .exceptionally(ex -> {
-                                            future.completeExceptionally(MetadataStoreException.wrap(ex.getCause()));
+                                            if (ex.getCause() instanceof BadVersionException) {
+                                                // The z-node exist now, let's overwrite it
+                                                internalStorePut(opPut);

Review comment:
       `future` is not completed here.

##########
File path: pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataStoreTest.java
##########
@@ -83,6 +84,30 @@ public void emptyStoreTest(String provider, Supplier<String> urlSupplier) throws
         }
     }
 
+    @Test(dataProvider = "impl")
+    public void concurrentPutTest(String provider, Supplier<String> urlSupplier) throws Exception {
+        if (!provider.equals("ZooKeeper")) {

Review comment:
       This case make sense to other impl too.

##########
File path: pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataStoreTest.java
##########
@@ -83,6 +84,30 @@ public void emptyStoreTest(String provider, Supplier<String> urlSupplier) throws
         }
     }
 
+    @Test(dataProvider = "impl")
+    public void concurrentPutTest(String provider, Supplier<String> urlSupplier) throws Exception {
+        if (!provider.equals("ZooKeeper")) {
+            return;
+        }
+        @Cleanup
+        MetadataStore store = MetadataStoreFactory.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
+
+        String data = "data";
+        String path = "/non-existing-key";
+        int concurrent = 50;
+        List<CompletableFuture<Stat>> resultList = new ArrayList<>();
+        while (concurrent > 0) {

Review comment:
       This will very likely introduces a flaky test.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org