dao-jun commented on code in PR #22024:
URL: https://github.com/apache/pulsar/pull/22024#discussion_r1493800083
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -442,14 +442,22 @@ private void takeSnapshotByTimeout() {
takeSnapshotIntervalTime, TimeUnit.MILLISECONDS);
}
+ private PositionImpl getPreviousPosition(PositionImpl position) {
+ return ((ManagedLedgerImpl)
topic.getManagedLedger()).getPreviousPosition(position);
+ }
+
+ private PositionImpl getLastConfirmedEntry() {
Review Comment:
seems we don't need the method.
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -287,8 +287,8 @@ private void handleTransactionMessage(TxnID txnId, Position
position) {
.checkAbortedTransaction(txnId)) {
ongoingTxns.put(txnId, (PositionImpl) position);
PositionImpl firstPosition =
ongoingTxns.get(ongoingTxns.firstKey());
- //max read position is less than first ongoing transaction message
position, so entryId -1
- maxReadPosition = PositionImpl.get(firstPosition.getLedgerId(),
firstPosition.getEntryId() - 1);
+ // max read position is less than first ongoing transaction
message position
+ maxReadPosition = getPreviousPosition(firstPosition);
Review Comment:
In fact, `entryId=-1` does not cause program exceptions, There are many uses
of this in pulsar. But if modified here, it is also acceptable
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -442,14 +442,22 @@ private void takeSnapshotByTimeout() {
takeSnapshotIntervalTime, TimeUnit.MILLISECONDS);
}
+ private PositionImpl getPreviousPosition(PositionImpl position) {
Review Comment:
remove the method and use `
topic.getManagedLedger()).getPreviousPosition(position);` directly is enough.
--
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]