korlov42 commented on code in PR #4690:
URL: https://github.com/apache/ignite-3/pull/4690#discussion_r1836455962
##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/TxManagerImpl.java:
##########
@@ -192,6 +196,11 @@ public class TxManagerImpl implements TxManager,
NetworkMessageHandler {
private final ReplicaService replicaService;
+ /** Registry of locally started active transactions. */
+ private final Map<UUID, InternalTransaction> transactions = new
ConcurrentHashMap<>();
+
+ private final TransactionsViewProvider txSystemViewProvider = new
TransactionsViewProvider(transactions);
Review Comment:
do we really need `viewProvide` as a member of `TxManager`? The former is
stateless object with no particular lifecycle. Besides, system views are
supposed to be registered only once. Therefore, it would be better I think to
not pollute manager with unnecessary members (e.g. create provider and
immediately call invoke `get()` method inside `systemViews()` method).
##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/TxManagerImpl.java:
##########
@@ -961,11 +978,35 @@ private HybridTimestamp
createBeginTimestampWithIncrementRwTxCounter() {
});
}
+ /** Called when a read-write transaction is finished. */
+ private void onFinishRwTx(UUID txId) {
+ decrementRwTxCount(txId);
+
+ unregister(txId);
+ }
+
private void decrementRwTxCount(UUID txId) {
localRwTxCounter.inUpdateRwTxCountLock(() -> {
localRwTxCounter.decrementRwTxCount(beginTimestamp(txId));
return null;
});
}
+
+ /**
+ * Puts a transaction into the registry.
+ *
+ * @param tx Transaction.
+ * @return Registered transaction.
+ */
+ private InternalTransaction register(InternalTransaction tx) {
+ transactions.put(tx.id(), tx);
Review Comment:
let's add an assertion to make sure we are not overriding another
transaction here (e.g. tx is registered only once; there is no duplicate ids at
least locally)
--
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]