merlimat commented on code in PR #25821:
URL: https://github.com/apache/pulsar/pull/25821#discussion_r3280295752


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/MetadataTransactionBuffer.java:
##########
@@ -136,46 +157,82 @@ private void recover() {
         }
         subscription = handle;
 
-        // Scan all /txn/op records for this segment, group by txnId.
-        Map<String, List<Position>> opsByTxn = new ConcurrentHashMap<>();
-        txnStore.listWritesBySegment(segmentName, new ScanConsumer() {
-            @Override
-            public void onNext(GetResult r) {
-                TxnOp op = TxnMetadataStore.fromJson(r.getValue(), 
TxnOp.class);
-                String txnIdKey = 
TxnPaths.txnIdFromOpPath(r.getStat().getPath());
-                if (txnIdKey == null) {
-                    return;
-                }
-                opsByTxn.computeIfAbsent(txnIdKey, k -> new ArrayList<>())
-                        .add(PositionFactory.create(op.getLedgerId(), 
op.getEntryId()));
-            }
+        // 1. Load durable watermark.
+        CompletableFuture<Void> watermarkLoad = 
txnStore.getSegmentWatermark(segmentName)
+                .thenAccept(opt -> {
+                    if (opt.isPresent()) {
+                        synchronized (lock) {

Review Comment:
   Agreed the coarse `synchronized(lock)` here isn't ideal. I'd like to keep 
this PR scoped to the durable visibility state and address the concurrency 
model as a follow-up. The single-writer approach looks like the best fit since 
the buffer is already driven from per-topic ordered callbacks — that would let 
us drop the lock without blocking Netty IO threads. Thanks for laying out the 
options.



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