You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "Lalant (via GitHub)" <gi...@apache.org> on 2026/01/06 08:04:27 UTC
[PR] Ignite 27005 add tx labels to public api [ignite-3]
Lalant opened a new pull request, #7349:
URL: https://github.com/apache/ignite-3/pull/7349
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Ignite 27005 add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2751510095
##########
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:
Ok, I noticed that read only requests don't support labels in builders. Is it expected?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Ignite 27005 add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2752983409
##########
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.
+ *
+ * <p>Transaction labels help identify and track transactions in system logs and the transaction system view.
+ * They can be useful for debugging and monitoring purposes.
+ *
+ * @param label Transaction label. Can be {@code null} to clear the label.
+ * @return {@code this} for chaining.
+ */
Review Comment:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2798157920
##########
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:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Ignite 27005 add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2751621446
##########
modules/transactions/src/integrationTest/java/org/apache/ignite/internal/tx/impl/ItTransactionLabelLoggingTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.tx.impl;
+
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.testframework.log4j2.LogInspector;
+import org.apache.ignite.tx.TransactionOptions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test to verify that transaction labels appear in logs for various negative scenarios.
+ */
+public class ItTransactionLabelLoggingTest extends ClusterPerTestIntegrationTest {
Review Comment:
Yes, but I decided to validated that not via logs and created dedicated test ItTransactionLabelPropagationTest.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Ignite 27005 add tx labels to public api [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
denis-chudov commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2743447897
##########
modules/transactions/src/integrationTest/java/org/apache/ignite/internal/tx/impl/ItTransactionLabelLoggingTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.tx.impl;
+
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.testframework.log4j2.LogInspector;
+import org.apache.ignite.tx.TransactionOptions;
+import org.junit.jupiter.api.Test;
+
Review Comment:
I remember you left a TODO in ItTransactionsSystemViewTest?
##########
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.
+ *
+ * <p>Transaction labels help identify and track transactions in system logs and the transaction system view.
+ * They can be useful for debugging and monitoring purposes.
+ *
+ * @param label Transaction label. Can be {@code null} to clear the label.
+ * @return {@code this} for chaining.
+ */
Review Comment:
Please mention that once a transaction label is set, it's immutable for the transaction.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
denis-chudov commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2789201468
##########
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
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2812429498
##########
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:
Done
##########
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:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 merged PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2798154648
##########
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:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
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
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2812430644
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1760,6 +1775,11 @@ private Publisher<BinaryRow> readWriteScan(
) {
assert !opCtx.txContext().isReadOnly();
+ TxContext.ReadWrite txContext = (TxContext.ReadWrite) opCtx.txContext();
+
+ // Update transaction state meta with label if present
Review Comment:
Done
##########
modules/api/src/main/java/org/apache/ignite/tx/TransactionOptions.java:
##########
@@ -80,4 +86,30 @@ 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 the transaction label. The label is included in diagnostic and observability outputs,
+ * such as logs and system views.
Review Comment:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Ignite 27005 add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2746115748
##########
modules/transactions/src/integrationTest/java/org/apache/ignite/internal/tx/impl/ItTransactionLabelLoggingTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.tx.impl;
+
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.testframework.log4j2.LogInspector;
+import org.apache.ignite.tx.TransactionOptions;
+import org.junit.jupiter.api.Test;
+
Review Comment:
You are right I forgot about that!
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2812431671
##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/TxManagerImpl.java:
##########
@@ -454,6 +454,10 @@ public InternalTransaction beginImplicit(HybridTimestampTracker timestampTracker
@Override
public InternalTransaction beginExplicit(HybridTimestampTracker timestampTracker, boolean readOnly, InternalTxOptions txOptions) {
+ if (readOnly && txOptions.txLabel() != null) {
+ throw new TransactionException(Common.ILLEGAL_ARGUMENT_ERR, "labels are not supported for read only transactions");
Review Comment:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "Lalant (via GitHub)" <gi...@apache.org>.
Lalant commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2798156136
##########
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:
Rephrased
##########
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:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27005 Add tx labels to public api [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
denis-chudov commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2811944800
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java:
##########
@@ -1760,6 +1775,11 @@ private Publisher<BinaryRow> readWriteScan(
) {
assert !opCtx.txContext().isReadOnly();
+ TxContext.ReadWrite txContext = (TxContext.ReadWrite) opCtx.txContext();
+
+ // Update transaction state meta with label if present
Review Comment:
```suggestion
// Update transaction state meta with label if present.
```
##########
modules/api/src/main/java/org/apache/ignite/tx/TransactionOptions.java:
##########
@@ -80,4 +86,30 @@ 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 the transaction label. The label is included in diagnostic and observability outputs,
+ * such as logs and system views.
Review Comment:
```suggestion
* such as logs, system views, etc.
```
Please add the same in getter.
##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/TxManagerImpl.java:
##########
@@ -454,6 +454,10 @@ public InternalTransaction beginImplicit(HybridTimestampTracker timestampTracker
@Override
public InternalTransaction beginExplicit(HybridTimestampTracker timestampTracker, boolean readOnly, InternalTxOptions txOptions) {
+ if (readOnly && txOptions.txLabel() != null) {
+ throw new TransactionException(Common.ILLEGAL_ARGUMENT_ERR, "labels are not supported for read only transactions");
Review Comment:
```suggestion
throw new TransactionException(Common.ILLEGAL_ARGUMENT_ERR, "Labels are not supported for read only transactions");
```
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Ignite 27005 add tx labels to public api [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
denis-chudov commented on code in PR #7349:
URL: https://github.com/apache/ignite-3/pull/7349#discussion_r2743553625
##########
modules/transactions/src/integrationTest/java/org/apache/ignite/internal/tx/impl/ItTransactionLabelLoggingTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.tx.impl;
+
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.testframework.log4j2.LogInspector;
+import org.apache.ignite.tx.TransactionOptions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test to verify that transaction labels appear in logs for various negative scenarios.
+ */
+public class ItTransactionLabelLoggingTest extends ClusterPerTestIntegrationTest {
Review Comment:
Could you please add a test showing that tx labels are propagated to primary replica nodes?
##########
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:
Why only used in scans?
Please propagate tx labels from transaction options to every request in this class, as a field of ReadWriteReplicaRequest.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org