visxu commented on issue #23661:
URL: https://github.com/apache/pulsar/issues/23661#issuecomment-2533377184

   Hi, @lhotari . I still regard this issue as a bug. Here's a case, if 
customer create a subscription only with properties, there will be a different 
behavior between rest API and admin CLI. e.g.
   
   ### Reproduce step
   1. create a topic and produce some messages.
   2. create subscriptions by admin CLI and rest API, only with properties 
setting, DO NOT specify the ledgerId, entryId, or Latest/Earliest.
   3. check the topic's stats-internal
   
   ### Expectation
   By default, the 2 subscriptions will consume message from the `Latest`.
   
   ### Actually
   Checking stats-internal, we got different `readPosition` value.
   
   ### Suggestion
   To set `ledgerId` and `entryId` default value to `Long.MAX_VALUE`
   ```java
   public class ResetCursorData {
       protected long ledgerId;
       protected long entryId;
       protected int partitionIndex = -1;
       protected boolean isExcluded = false;
       protected int batchIndex = -1;
       protected Map<String, String> properties;
       
   }   
   ```
   
   ### Execution record
   ```shell
   visxu➜~/pulsar-cluster-3.0.6» ./pulsar-1/bin/pulsar-admin topics create 
public/default/topic-x                                                          
                                                               [8:38:50]
   visxu➜~/pulsar-cluster-3.0.6» ./pulsar-1/bin/pulsar-client produce 
public/default/topic-x --messages "Hello, Pulsar1"                              
                                                                    [8:39:03]
   visxu➜~/pulsar-cluster-3.0.6» ./pulsar-1/bin/pulsar-client produce 
public/default/topic-x --messages "Hello, Pulsar2"                              
                                                                    [8:39:24]
   visxu➜~/pulsar-cluster-3.0.6» ./pulsar-1/bin/pulsar-client produce 
public/default/topic-x --messages "Hello, Pulsar3"                              
                                                                    [8:39:29]
   visxu➜~/pulsar-cluster-3.0.6» ./pulsar-1/bin/pulsar-admin topics 
create-subscription --subscription sub-x-1 --property key1=value1 
public/default/topic-x  
   
   visxu➜~/pulsar-cluster-3.0.6» curl --location --request PUT 
'http://127.0.0.1:18080/admin/v2/persistent/public/default/topic-x/subscription/sub-x-2'
 \                                                                 [8:40:03]
   --header 'Content-Type: application/json' \
   --data '{
       "properties": {
           "key2": "value2"
       }
   }'
   visxu➜~/pulsar-cluster-3.0.6» ./pulsar-1/bin/pulsar-admin topics 
stats-internal public/default/topic-x                                           
                                                                      [8:40:37]
   {
     "entriesAddedCounter" : 6,
     "numberOfEntries" : 6,
     "totalSize" : 327,
     "currentLedgerEntries" : 6,
     "currentLedgerSize" : 327,
     "lastLedgerCreatedTimestamp" : "2024-12-11T08:39:03.068+08:00",
     "waitingCursorsCount" : 0,
     "pendingAddEntriesCount" : 0,
     "lastConfirmedEntry" : "63:5",
     "state" : "LedgerOpened",
     "ledgers" : [ {
       "ledgerId" : 63,
       "entries" : 0,
       "size" : 0,
       "offloaded" : false,
       "underReplicated" : false
     } ],
     "cursors" : {
       "sub-x-1" : {
         "markDeletePosition" : "63:5",
         "readPosition" : "63:6",
         "waitingReadOp" : false,
         "pendingReadOps" : 0,
         "messagesConsumedCounter" : 6,
         "cursorLedger" : 64,
         "cursorLedgerLastEntry" : 1,
         "individuallyDeletedMessages" : "[]",
         "lastLedgerSwitchTimestamp" : "2024-12-11T08:40:17.804+08:00",
         "state" : "Open",
         "active" : false,
         "numberOfEntriesSinceFirstNotAckedMessage" : 1,
         "totalNonContiguousDeletedMessagesRange" : 0,
         "subscriptionHavePendingRead" : false,
         "subscriptionHavePendingReplayRead" : false,
         "properties" : { }
       },
       "sub-x-2" : {
         "markDeletePosition" : "63:-1",
         "readPosition" : "63:0",
         "waitingReadOp" : false,
         "pendingReadOps" : 0,
         "messagesConsumedCounter" : 0,
         "cursorLedger" : 65,
         "cursorLedgerLastEntry" : 1,
         "individuallyDeletedMessages" : "[]",
         "lastLedgerSwitchTimestamp" : "2024-12-11T08:40:34.635+08:00",
         "state" : "Open",
         "active" : false,
         "numberOfEntriesSinceFirstNotAckedMessage" : 1,
         "totalNonContiguousDeletedMessagesRange" : 0,
         "subscriptionHavePendingRead" : false,
         "subscriptionHavePendingReplayRead" : false,
         "properties" : { }
       }
     },
     "schemaLedgers" : [ ],
     "compactedLedger" : {
       "ledgerId" : -1,
       "entries" : -1,
       "size" : -1,
       "offloaded" : false,
       "underReplicated" : false
     }
   }
   visxu➜~/pulsar-cluster-3.0.6»                                                
                                                                                
                                                          [8:40:49]
   ```
   


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

Reply via email to