Lalant commented on code in PR #7482:
URL: https://github.com/apache/ignite-3/pull/7482#discussion_r2917621823
##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/VolatileTxStateMetaStorage.java:
##########
@@ -115,6 +119,53 @@ public void initialize(InternalTransaction tx, @Nullable
String txLabel) {
});
}
+ /**
+ * Atomically updates transaction metadata (TxStateMeta) without
validating TxState transitions.
+ * Use this only for metadata-only changes that do not affect
state-derived fields
+ * (currently exception info or labels), and never to update TxState
itself.
+ *
+ * @param txId Transaction id.
+ * @param updater Transaction meta updater.
+ * @return Updated transaction state.
+ */
+ public @Nullable <T extends TxStateMeta> T enrichMeta(UUID txId,
+ Function<@Nullable TxStateMeta, TxStateMeta> updater) {
+ return (T) txStateMap.compute(txId, (k, oldMeta) -> {
+ TxStateMeta newMeta = updater.apply(oldMeta);
+
+ if (newMeta == null) {
+ if (oldMeta != null) {
+ LOG.info("Skipped removing transaction state in enrichMeta
[txId={}].", txId);
+ }
+
+ return oldMeta;
+ }
+
+ if (!isEnrichAllowed(txId, oldMeta, newMeta)) {
+ return oldMeta;
+ }
+
+ return newMeta;
+ });
+ }
+
+ private static boolean isEnrichAllowed(UUID txId, @Nullable TxStateMeta
oldMeta, TxStateMeta newMeta) {
+ if (oldMeta == null) {
+ LOG.info("Skipped creating transaction state in enrichMeta
[txId={}].", txId);
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]