Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
de37e61
[feat][txn] implement the SnapshotSegmentAbortedTxnProcessor
liangyepianzhou Nov 1, 2022
6cc07cb
optimize
liangyepianzhou Nov 1, 2022
08c2da3
checkstyle
liangyepianzhou Nov 1, 2022
b298b0e
optimize
liangyepianzhou Nov 3, 2022
b6f8b47
store the max persistent position of aborted txn marker in a segment …
liangyepianzhou Nov 5, 2022
eca6d33
optimize test
liangyepianzhou Nov 5, 2022
564b6cd
fix some comments
liangyepianzhou Nov 14, 2022
52ad0ae
fix some comments
liangyepianzhou Dec 20, 2022
291d9e2
use single set to check aborted transaction ID.
liangyepianzhou Dec 20, 2022
20bcd50
use single set to check aborted transaction ID.
liangyepianzhou Dec 20, 2022
75af3d8
Merge remote-tracking branch 'apache/master' into xiangying/pip/snaps…
liangyepianzhou Dec 29, 2022
80d87b9
fix some comments
liangyepianzhou Dec 29, 2022
e2664cf
fix some comments
liangyepianzhou Dec 29, 2022
906d942
optimize data struct
liangyepianzhou Dec 29, 2022
78424f9
fix some comments
liangyepianzhou Jan 3, 2023
22ccc5b
optimize
liangyepianzhou Jan 9, 2023
71fe2db
fix uncompleted future.
liangyepianzhou Jan 9, 2023
fc9ef84
optimize and add an API test
liangyepianzhou Jan 10, 2023
dfc30f0
optimize some comments
liangyepianzhou Jan 13, 2023
8418e34
delete persistentSnapshotIndexes
liangyepianzhou Jan 13, 2023
c8a1344
fix test
liangyepianzhou Jan 13, 2023
374f600
fix some comments and add notes
liangyepianzhou Jan 19, 2023
96e34d5
optimize recover indexes
liangyepianzhou Jan 19, 2023
8fa0606
optimize notes
liangyepianzhou Jan 28, 2023
9e6af2a
optimize notes
liangyepianzhou Jan 28, 2023
204a5ff
fix some test
liangyepianzhou Feb 3, 2023
b46e38b
fix some comment
liangyepianzhou Feb 3, 2023
d2210e3
fix some comment
liangyepianzhou Feb 3, 2023
ee8a671
Optimize the logic of clearing and add test.
liangyepianzhou Feb 3, 2023
016d3f9
license and checkstyle
liangyepianzhou Feb 3, 2023
b498a2d
fix test
liangyepianzhou Feb 3, 2023
1edc5b2
fix some comments
liangyepianzhou Feb 8, 2023
5eec111
fix some comments
liangyepianzhou Feb 8, 2023
d095166
fix some comments
liangyepianzhou Feb 8, 2023
34c9f35
fix some comments
liangyepianzhou Feb 9, 2023
00eb60e
Only update index when execute the latest task
liangyepianzhou Feb 9, 2023
f4bf25f
Do not retry the task immediately if the task happens exception.
liangyepianzhou Feb 10, 2023
4ad3c7a
fix test
liangyepianzhou Feb 10, 2023
20b9681
separate catch exception
liangyepianzhou Feb 10, 2023
1c06fcf
update maxReadPosition after putting aborted txn ID
liangyepianzhou Feb 10, 2023
af2ccab
add notes
liangyepianzhou Feb 10, 2023
c7c1294
add notes
liangyepianzhou Feb 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected CompletableFuture<SystemTopicClient<T>> getTransactionBufferSystemTopi
}
return CompletableFuture.completedFuture(clients.computeIfAbsent(systemTopicName,
(v) -> namespaceEventsSystemTopicFactory
.createTransactionBufferSystemTopicClient(topicName.getNamespaceObject(),
.createTransactionBufferSystemTopicClient(systemTopicName,
this, schemaType)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ public TopicPoliciesSystemTopicClient createTopicPoliciesSystemTopicClient(Names
}

public <T> TransactionBufferSnapshotBaseSystemTopicClient<T> createTransactionBufferSystemTopicClient(
NamespaceName namespaceName, SystemTopicTxnBufferSnapshotService<T>
TopicName systemTopicName, SystemTopicTxnBufferSnapshotService<T>
systemTopicTxnBufferSnapshotService, Class<T> schemaType) {
TopicName topicName = TopicName.get(TopicDomain.persistent.value(), namespaceName,
SystemTopicNames.TRANSACTION_BUFFER_SNAPSHOT);
log.info("Create transaction buffer snapshot client, topicName : {}", topicName.toString());
return new TransactionBufferSnapshotBaseSystemTopicClient(client, topicName,
log.info("Create transaction buffer snapshot client, topicName : {}", systemTopicName.toString());
return new TransactionBufferSnapshotBaseSystemTopicClient(client, systemTopicName,
systemTopicTxnBufferSnapshotService, schemaType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public SystemTopicClient<T> getSystemTopic() {
protected CompletableFuture<Writer<T>> newWriterAsyncInternal() {
return client.newProducer(Schema.AVRO(schemaType))
.topic(topicName.toString())
.enableBatching(false)
.createAsync().thenApply(producer -> {
if (log.isDebugEnabled()) {
log.debug("[{}] A new {} writer is created", topicName, schemaType.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.pulsar.broker.transaction.buffer;

import java.util.concurrent.CompletableFuture;
import org.apache.bookkeeper.mledger.Position;
import org.apache.bookkeeper.mledger.impl.PositionImpl;
import org.apache.pulsar.client.api.transaction.TxnID;

Expand All @@ -30,9 +29,9 @@ public interface AbortedTxnProcessor {
* After the transaction buffer writes a transaction aborted marker to the topic,
* the transaction buffer will put the aborted txnID and the aborted marker position to AbortedTxnProcessor.
* @param txnID aborted transaction ID.
* @param position the position of the abort txnID
* @param abortedMarkerPersistentPosition the position of the abort txn marker.
*/
void putAbortedTxnAndPosition(TxnID txnID, PositionImpl position);
void putAbortedTxnAndPosition(TxnID txnID, PositionImpl abortedMarkerPersistentPosition);

/**
* Clean up invalid aborted transactions.
Expand All @@ -42,10 +41,9 @@ public interface AbortedTxnProcessor {
/**
* Check whether the transaction ID is an aborted transaction ID.
* @param txnID the transaction ID that needs to be checked.
* @param readPosition the read position of the transaction message, can be used to find the segment.
* @return a boolean, whether the transaction ID is an aborted transaction ID.
*/
boolean checkAbortedTransaction(TxnID txnID, Position readPosition);
boolean checkAbortedTransaction(TxnID txnID);

/**
* Recover transaction buffer by transaction buffer snapshot.
Expand All @@ -58,7 +56,7 @@ public interface AbortedTxnProcessor {
* Delete the transaction buffer aborted transaction snapshot.
* @return a completableFuture.
*/
CompletableFuture<Void> deleteAbortedTxnSnapshot();
CompletableFuture<Void> clearAbortedTxnSnapshot();

/**
* Take aborted transactions snapshot.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.mledger.Position;
import org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl;
import org.apache.bookkeeper.mledger.impl.PositionImpl;
import org.apache.commons.collections4.map.LinkedMap;
Expand Down Expand Up @@ -57,11 +56,16 @@ public SingleSnapshotAbortedTxnProcessorImpl(PersistentTopic topic) {
this.takeSnapshotWriter = this.topic.getBrokerService().getPulsar()
.getTransactionBufferSnapshotServiceFactory()
.getTxnBufferSnapshotService().createWriter(TopicName.get(topic.getName()));
this.takeSnapshotWriter.exceptionally((ex) -> {
log.error("{} Failed to create snapshot writer", topic.getName());
Comment thread
liangyepianzhou marked this conversation as resolved.
topic.close();
return null;
});
}

@Override
public void putAbortedTxnAndPosition(TxnID abortedTxnId, PositionImpl position) {
aborts.put(abortedTxnId, position);
public void putAbortedTxnAndPosition(TxnID abortedTxnId, PositionImpl abortedMarkerPersistentPosition) {
aborts.put(abortedTxnId, abortedMarkerPersistentPosition);
}

//In this implementation we clear the invalid aborted txn ID one by one.
Expand All @@ -78,7 +82,7 @@ public void trimExpiredAbortedTxns() {
}

@Override
public boolean checkAbortedTransaction(TxnID txnID, Position readPosition) {
public boolean checkAbortedTransaction(TxnID txnID) {
return aborts.containsKey(txnID);
}

Expand Down Expand Up @@ -127,14 +131,12 @@ public CompletableFuture<PositionImpl> recoverFromSnapshot() {
}

@Override
public CompletableFuture<Void> deleteAbortedTxnSnapshot() {
public CompletableFuture<Void> clearAbortedTxnSnapshot() {
return this.takeSnapshotWriter.thenCompose(writer -> {
TransactionBufferSnapshot snapshot = new TransactionBufferSnapshot();
snapshot.setTopicName(topic.getName());
return writer.deleteAsync(snapshot.getTopicName(), snapshot);
}).thenRun(() -> {
log.info("[{}] Successes to delete the aborted transaction snapshot", this.topic);
});
}).thenRun(() -> log.info("[{}] Successes to delete the aborted transaction snapshot", this.topic));
}

@Override
Expand Down
Loading