jack-tristan commented on issue #9478:
URL: https://github.com/apache/pulsar/issues/9478#issuecomment-800013912


   @codelipenghui 
   The experimental results are not in line with expectations 
   
   namespace policy base on pulsar 2.6.3
   ```
   # bin/pulsar-admin namespaces get-retention test-zdh/compact-1
   {
     "retentionTimeInMinutes" : 0,
     "retentionSizeInMB" : 0
   }
   
   
   # bin/pulsar-admin namespaces get-compaction-threshold test-zdh/compact-1
   512
   
   ```
   
   Experiment process: 
   one producer, one million messages, ten thousand keys, and one consumer's 
over subscription 
   
   ```
   # one producer,1 million messages
   producer = client.newProducer(Schema.STRING)
           .compressionType(CompressionType.LZ4)
           .topic("persistent://test-zdh/compact-1/compact-str-v1")
           .create();
   
   
   String str = null;
   for (int i=0; i < num; i++){
       str = "num is a " + i;
       String key = "key-" + i % 10000; //ten thousand keys
       MessageId messageId = producer
               .newMessage()
               .key(key)
               .value(str)
               .send();
       System.out.println("num: " + i);
       System.out.println(key);
       System.out.println(messageId.toString());
   }
   
   # one consumer 
   consumer = client
           .newConsumer(Schema.STRING)
           .topic("persistent://test-zdh/compact-1/compact-str-v1")
           
.subscriptionName("sub-cluster-b-test-zdh-compact-1-compact-str-v1-failover-1")
           .subscriptionType(SubscriptionType.Failover) // exclusive or failover
           .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
           .readCompacted(true) //exclusive or failover persistent subscriptions
           .subscribe();
   
   ```
   
   Experimental result:  The expectation is 10000, but the result is 7355 
   ```
   presto> select count(*) as num from 
pulsar."test-zdh/compact-1"."compact-str-v1";
    num
   ------
    7355
   
   presto> select count(distinct(__key__)) as num from 
pulsar."test-zdh/compact-1"."compact-str-v1";
    num
   ------
    7355
   
   ```
   
   ```
   # new consumer subscription failover-2, consume messages num is 7355 
   consumer = client
           .newConsumer(Schema.STRING)
           .topic("persistent://test-zdh/compact-1/compact-str-v1")
           
.subscriptionName("sub-cluster-b-test-zdh-compact-1-compact-str-v1-failover-2")
           .subscriptionType(SubscriptionType.Failover) // exclusive or failover
           .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
           .readCompacted(true) //exclusive or failover persistent subscriptions
           .subscribe();
   ```


----------------------------------------------------------------
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]


Reply via email to