You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by rp...@apache.org on 2024/12/20 16:40:10 UTC

(ignite-3) branch main updated: IGNITE-24052 Stop listening to configuration changes on OrphanDetector stop (#4940)

This is an automated email from the ASF dual-hosted git repository.

rpuch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 8e3fea0176 IGNITE-24052 Stop listening to configuration changes on OrphanDetector stop (#4940)
8e3fea0176 is described below

commit 8e3fea0176919a0f547bd829780c5dcb191c0f30
Author: Roman Puchkovskiy <ro...@gmail.com>
AuthorDate: Fri Dec 20 20:40:04 2024 +0400

    IGNITE-24052 Stop listening to configuration changes on OrphanDetector stop (#4940)
---
 .../ignite/internal/tx/impl/OrphanDetector.java     | 21 ++++++++++++++++-----
 .../ignite/internal/tx/impl/OrphanDetectorTest.java | 10 +++++++++-
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/OrphanDetector.java b/modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/OrphanDetector.java
index 1a3446c578..e59684f1ee 100644
--- a/modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/OrphanDetector.java
+++ b/modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/OrphanDetector.java
@@ -31,6 +31,7 @@ import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.Executor;
 import org.apache.ignite.configuration.ConfigurationValue;
+import org.apache.ignite.configuration.notifications.ConfigurationListener;
 import org.apache.ignite.internal.event.EventListener;
 import org.apache.ignite.internal.logger.IgniteLogger;
 import org.apache.ignite.internal.logger.Loggers;
@@ -91,6 +92,14 @@ public class OrphanDetector {
      */
     private long checkTxStateInterval;
 
+    private final ConfigurationListener<Long> checkTxStateIntervalListener = ctx -> {
+        this.checkTxStateInterval = ctx.newValue();
+
+        return nullCompletedFuture();
+    };
+
+    private volatile @Nullable ConfigurationValue<Long> checkTxStateIntervalProvider;
+
     /** Local transaction state storage. */
     private VolatileTxStateMetaStorage txLocalStateStorage;
 
@@ -125,13 +134,10 @@ public class OrphanDetector {
      */
     public void start(VolatileTxStateMetaStorage txLocalStateStorage, ConfigurationValue<Long> checkTxStateIntervalProvider) {
         this.txLocalStateStorage = txLocalStateStorage;
+        this.checkTxStateIntervalProvider = checkTxStateIntervalProvider;
         this.checkTxStateInterval = checkTxStateIntervalProvider.value();
 
-        checkTxStateIntervalProvider.listen(ctx -> {
-            this.checkTxStateInterval = ctx.newValue();
-
-            return nullCompletedFuture();
-        });
+        checkTxStateIntervalProvider.listen(checkTxStateIntervalListener);
 
         lockManager.listen(LockEvent.LOCK_CONFLICT, lockConflictListener);
     }
@@ -143,6 +149,11 @@ public class OrphanDetector {
         busyLock.block();
 
         lockManager.removeListener(LockEvent.LOCK_CONFLICT, lockConflictListener);
+
+        ConfigurationValue<Long> localCheckTxStateIntervalProvider = checkTxStateIntervalProvider;
+        if (localCheckTxStateIntervalProvider != null) {
+            localCheckTxStateIntervalProvider.stopListen(checkTxStateIntervalListener);
+        }
     }
 
     /**
diff --git a/modules/transactions/src/test/java/org/apache/ignite/internal/tx/impl/OrphanDetectorTest.java b/modules/transactions/src/test/java/org/apache/ignite/internal/tx/impl/OrphanDetectorTest.java
index f690790339..9ecd188562 100644
--- a/modules/transactions/src/test/java/org/apache/ignite/internal/tx/impl/OrphanDetectorTest.java
+++ b/modules/transactions/src/test/java/org/apache/ignite/internal/tx/impl/OrphanDetectorTest.java
@@ -61,6 +61,7 @@ import org.apache.ignite.internal.tx.TxStateMeta;
 import org.apache.ignite.internal.tx.configuration.TransactionConfiguration;
 import org.apache.ignite.network.ClusterNode;
 import org.apache.ignite.network.NetworkAddress;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -103,6 +104,8 @@ public class OrphanDetectorTest extends BaseIgniteAbstractTest {
 
     private TransactionIdGenerator idGenerator;
 
+    private OrphanDetector orphanDetector;
+
     private static LockManager lockManager() {
         HeapLockManager lockManager = new HeapLockManager();
         lockManager.start(new WaitDieDeadlockPreventionPolicy());
@@ -117,7 +120,7 @@ public class OrphanDetectorTest extends BaseIgniteAbstractTest {
 
         resolutionCount.set(0);
 
-        OrphanDetector orphanDetector = new OrphanDetector(
+        orphanDetector = new OrphanDetector(
                 topologyService,
                 replicaService,
                 placementDriverHelper,
@@ -135,6 +138,11 @@ public class OrphanDetectorTest extends BaseIgniteAbstractTest {
         orphanDetector.start(txStateMetaStorage, txConfiguration.abandonedCheckTs());
     }
 
+    @AfterEach
+    void cleanup() {
+        orphanDetector.stop();
+    }
+
     @Test
     void testNoTriggerNoState() {
         UUID orphanTxId = idGenerator.transactionIdFor(clock.now());