denis-chudov commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2788954087


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1803,6 +1810,25 @@ protected CompletableFuture<Void> onClose(boolean 
intentionallyClose, long scanI
         };
     }
 
+    /**
+     * Updates transaction meta with the label and commit partition, if a 
label is present.
+     *
+     * <p>This is used for tracking labeled transactions in the meta storage; 
unlabeled transactions are ignored.
+     *
+     * @param txContext Transaction context.
+     * @param commitPartition Commit partition to record (may be {@code null}).
+     */
+    private void updateLabel(TxContext txContext, @Nullable ZonePartitionId 
commitPartition) {

Review Comment:
   yes, it is - and txn meta shouldn't be created for RO txns



##########
modules/api/src/main/java/org/apache/ignite/tx/TransactionOptions.java:
##########
@@ -80,4 +86,29 @@ public TransactionOptions readOnly(boolean readOnly) {
 
         return this;
     }
+
+    /**
+     * Returns transaction label. The label is used for identification in logs 
and system views.
+     *
+     * @return Transaction label, or {@code null} if not set.
+     */
+    @Nullable
+    public String label() {
+        return label;
+    }
+
+    /**
+     * Sets transaction label. The label is used for identification in logs 
and system views.

Review Comment:
   > in logs and system views
   
   It's public API, so I would rephrase it in a way that wouldn't look like 
limitation. For example, `is included in diagnostic and observability outputs, 
like system views, etc.". WDYT?



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/IgniteTransactionsImpl.java:
##########
@@ -54,6 +54,7 @@ public Transaction begin(@Nullable TransactionOptions 
options) {
                 ? InternalTxOptions.defaults()
                 : InternalTxOptions.builder()
                         .timeoutMillis(options.timeoutMillis())
+                        .txLabel(options.label())

Review Comment:
   Let's also throw exception from TxManagerImpl#beginExplicit if tx label is 
set and txn is read only, like "labels are not supported for read only 
transactions".



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1634,6 +1649,10 @@ private Publisher<BinaryRow> readOnlyScan(
     ) {
         assert opCtx.txContext().isReadOnly();
 
+        TxContext.ReadOnly txContext = (TxContext.ReadOnly) opCtx.txContext();
+
+        updateLabel(txContext, null);

Review Comment:
   Let's leave it only in read write context.
   Labels are not propagated with read only requests, basically they are needed 
only for rw txns (btw, maybe throw exception from TxManagerImpl#beginExplicit 
if tx label is set and txn is read only?). The main reason is that transaction 
meta is not created for read only transactions, they don't have state on remote 
nodes except opened cursors.
   



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/TransactionExpirationRegistry.java:
##########
@@ -125,10 +125,8 @@ private boolean isExpired(long expirationTime) {
 
     private void abortTransaction(InternalTransaction tx) {
         tx.rollbackTimeoutExceededAsync().whenComplete((res, ex) -> {
-            if (ex != null) {

Review Comment:
   why?



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