Nicklee007 commented on PR #15474:
URL: https://github.com/apache/pulsar/pull/15474#issuecomment-1120119651

   > Good catch. This patch solved the problem to some extent, I think the 
solution is that the newly created persistent subscription 'cursor position' is 
always greater than 'message-TTL' and the 'message-TTL' policy is enabled.
   > 
   > I have two questions:
   > 
   > * 1
   > 
   > > And then if we have a flink task consumer the topic( use reader to 
consumer and mark position by another durable cursor), the client will always 
reset the durable cursor to the position.
   > 
   > why not use nodurable Reader ?
   > 
   > * 2
   > 
   > ```java
   > ledgerClosed(lh);
   > createLedgerAfterClosed();
   > ```
   > 
   > This should ensure that a new-leadger is always created when the 
old-leadger is closed. If this is necessary, a comment should be added to 
remind others later, better have a unit test to ensure that.
   
   @poorbarcode yes, but only enable 'message-TTL' policy is not enough. As the 
case 2, if we have subscription cursor and not active consumer, the   
`MessageExpiryMonitor`  only can reset `slowestReaderPosition` 
to(olderLedgerId, entryNum ), cannot move the cursor to the newest empty 
ledger, we move slowestReaderPosition through the `ConsumedLedgersMonitor` to 
check if the ledger consumed completely,  we'll reset slowestReaderPosition and 
then trigger `trimConsumedLedgersInBackground` in one task , this will be more 
effective and probability of `slowestReaderPosition` value  being covered is 
lower, even `slowestReaderPosition` is covered ,we could reset it to newest 
position in next `MessageExpiryMonitor` time.
   
   > why not use nodurable Reader ?
   Because we have many flink job use the StreamNative's pulsar-connector which 
use a reader to consume data and need mark consumer position  by another 
durable cursor when flink job restart which will be used. So there are two 
cursor.


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