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

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new a000164  ARTEMIS-2721 Activation keeps retrying even after 
server.stop()
     new 85f26ce  This closes #3090
a000164 is described below

commit a00016416907e3f92356fe31b0311cc8335b7204
Author: Clebert Suconic <[email protected]>
AuthorDate: Fri Apr 17 12:40:26 2020 -0400

    ARTEMIS-2721 Activation keeps retrying even after server.stop()
    
    This won't be an issue on a real server (Production system)
    
    however, on the testsuite or while embedded this could cause issues,
    if a same instance is stopped then started.
    
    This is the reason why BackupAuthenticationTest was intermittently failing.
    
    I also adapted the test since I would need to stop the server and 
reactivate it in order to change the configuration.
    The previous test wasn't acting like a real server.
---
 .../core/server/cluster/ClusterController.java      | 21 +++++++++++++++++----
 .../core/server/impl/ActiveMQServerImpl.java        |  8 ++++++--
 .../server/impl/SharedNothingBackupActivation.java  |  7 +++++--
 .../cluster/failover/BackupAuthenticationTest.java  |  8 ++++----
 4 files changed, 32 insertions(+), 12 deletions(-)

diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
index 42fcf75..d6d948e 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
@@ -92,6 +92,9 @@ public class ClusterController implements ActiveMQComponent {
 
    @Override
    public void start() throws Exception {
+      if (logger.isDebugEnabled()) {
+         logger.debug("Starting Cluster Controller " + 
System.identityHashCode(this) + " for server " + server);
+      }
       if (started)
          return;
       //set the default locator that will be used to connecting to the default 
cluster.
@@ -129,13 +132,17 @@ public class ClusterController implements 
ActiveMQComponent {
 
    @Override
    public void stop() throws Exception {
+      if (logger.isDebugEnabled()) {
+
+         logger.debug("Stopping Cluster Controller " + 
System.identityHashCode(this) + " for server " + this.server);
+      }
+      started = false;
       //close all the locators
       for (ServerLocatorInternal serverLocatorInternal : locators.values()) {
          serverLocatorInternal.close();
       }
       //stop the quorum manager
       quorumManager.stop();
-      started = false;
    }
 
    @Override
@@ -428,14 +435,20 @@ public class ClusterController implements 
ActiveMQComponent {
       @Override
       public void run() {
          try {
-            serverLocator.connect();
-            if (serverLocator == replicationLocator) {
-               replicationClusterConnectedLatch.countDown();
+            if (started) {
+               serverLocator.connect();
+               if (serverLocator == replicationLocator) {
+                  replicationClusterConnectedLatch.countDown();
+               }
             }
          } catch (ActiveMQException e) {
             if (!started) {
                return;
             }
+            if (logger.isDebugEnabled()) {
+
+               logger.debug("retry on Cluster Controller " + 
System.identityHashCode(ClusterController.this) + " server = " + server);
+            }
             server.getScheduledPool().schedule(this, 
serverLocator.getRetryInterval(), TimeUnit.MILLISECONDS);
          }
       }
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 8e5af5b..798d7d9 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -1059,7 +1059,9 @@ public class ActiveMQServerImpl implements ActiveMQServer 
{
     */
    void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, 
boolean restarting, boolean isShutdown) {
 
-      logger.debug("Stopping server");
+      if (logger.isDebugEnabled()) {
+         logger.debug("Stopping server " + this);
+      }
 
       synchronized (this) {
          if (state == SERVER_STATE.STOPPED || state == SERVER_STATE.STOPPING) {
@@ -3899,7 +3901,9 @@ public class ActiveMQServerImpl implements ActiveMQServer 
{
       public void run() {
          lockActivation();
          try {
-            runnable.run();
+            if (state != SERVER_STATE.STOPPED && state != 
SERVER_STATE.STOPPING) {
+               runnable.run();
+            }
          } finally {
             unlockActivation();
          }
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java
index 3c199d2..36c9c9f 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java
@@ -275,8 +275,11 @@ public final class SharedNothingBackupActivation extends 
Activation {
                         if (logger.isTraceEnabled()) {
                            logger.trace("Calling activeMQServer.stop() and 
start() to restart the server");
                         }
-                        activeMQServer.stop();
-                        activeMQServer.start();
+                        if (activeMQServer.getState() != 
ActiveMQServer.SERVER_STATE.STOPPED &&
+                            activeMQServer.getState() != 
ActiveMQServer.SERVER_STATE.STOPPING) {
+                           activeMQServer.stop();
+                           activeMQServer.start();
+                        }
                      } catch (Exception e) {
                         
ActiveMQServerLogger.LOGGER.errorRestartingBackupServer(e, activeMQServer);
                      }
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java
index 822defd..de0ff59 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupAuthenticationTest.java
@@ -44,7 +44,8 @@ public class BackupAuthenticationTest extends 
FailoverTestBase {
    }
 
    @Test
-   public void testPasswordSetting() throws Exception {
+   public void testWrongPasswordSetting() throws Exception {
+      Wait.assertTrue(liveServer.getServer()::isActive);
       waitForServerToStart(liveServer.getServer());
       backupServer.start();
       assertTrue(latch.await(5, TimeUnit.SECONDS));
@@ -54,9 +55,8 @@ public class BackupAuthenticationTest extends 
FailoverTestBase {
        */
       Wait.waitFor(() -> !backupServer.isStarted());
       assertFalse("backup should have stopped", backupServer.isStarted());
-      backupConfig.setClusterPassword(CLUSTER_PASSWORD);
-      backupServer.start();
-      waitForRemoteBackup(null, 5, true, backupServer.getServer());
+      backupServer.stop();
+      liveServer.stop();
    }
 
    @Override

Reply via email to