You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ib...@apache.org on 2022/02/25 10:41:40 UTC

[ignite] branch master updated: IGNITE-16623 Cover speed-based throttling breakdown fix with integration test (#9850)

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

ibessonov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new e5af20c  IGNITE-16623 Cover speed-based throttling breakdown fix with integration test (#9850)
e5af20c is described below

commit e5af20c558bebbb7fd724ed5e25daa60a3037807
Author: Roman Puchkovskiy <ro...@gmail.com>
AuthorDate: Fri Feb 25 14:40:59 2022 +0400

    IGNITE-16623 Cover speed-based throttling breakdown fix with integration test (#9850)
    
    In IGNITE-16581, a speed-based throttling breakage bug was fixed, but we only covered the fix with local JUnit tests. Here, we add an integration test to rest assured.
---
 .../pagemem/SpeedBasedThrottleBreakdownTest.java   | 128 +++++++++++++++++++++
 .../ignite/testsuites/IgnitePdsTestSuite.java      |   2 +
 2 files changed, 130 insertions(+)

diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/SpeedBasedThrottleBreakdownTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/SpeedBasedThrottleBreakdownTest.java
new file mode 100644
index 0000000..4c9d1ca
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/SpeedBasedThrottleBreakdownTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.processors.cache.persistence.pagemem;
+
+import java.util.Arrays;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.failure.FailureHandler;
+import org.apache.ignite.failure.StopNodeFailureHandler;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+
+/**
+ * Tests for the cases when high load might break down speed-based throttling protection.
+ *
+ * @see PagesWriteSpeedBasedThrottle
+ */
+@RunWith(Parameterized.class)
+public class SpeedBasedThrottleBreakdownTest extends GridCommonAbstractTest {
+    /***/
+    @Parameterized.Parameter
+    public boolean useSpeedBasedThrottling;
+
+    /** Parameters. */
+    @Parameterized.Parameters(name = "Use speed-based throttling: {0}")
+    public static Iterable<Boolean[]> data() {
+        return Arrays.asList(
+            new Boolean[] {true},
+            new Boolean[] {false}
+        );
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        DataStorageConfiguration dbCfg = new DataStorageConfiguration()
+                .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+                        // tiny CP buffer is required to reproduce this problem easily
+                        .setCheckpointPageBufferSize(3_000_000)
+                        .setPersistenceEnabled(true))
+                .setCheckpointFrequency(200)
+                .setWriteThrottlingEnabled(useSpeedBasedThrottling);
+
+        cfg.setDataStorageConfiguration(dbCfg);
+
+        cfg.setConsistentId(gridName);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        stopAllGrids();
+
+        super.beforeTest();
+
+        cleanPersistenceDir();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        super.afterTest();
+
+        cleanPersistenceDir();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 3L * 60 * 1000;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected FailureHandler getFailureHandler(String igniteInstanceName) {
+        return new StopNodeFailureHandler();
+    }
+
+    /**
+     * There was the following bug: at the very start of a checkpoint, the checkpoint progress information was not yet
+     * available to the speed-based throttler, in which case it did not apply throttling. If during that short period
+     * there was high pressure on the Checkpoint Buffer, the buffer would be exhausted causing node failure.
+     *
+     * It was easy to reproduce with a small Checkpoint Buffer. This test does exactly this: with a small
+     * Checkpoint Buffer, it creates a spike of load on it. The test is successful if the CP Buffer protection
+     * does not break down and no exception gets thrown as a result.
+     *
+     * @throws Exception if something goes wrong.
+     */
+    @Test
+    public void speedBasedThrottleShouldNotAllowCPBufferBreakdownWhenCPBufferIsSmall() throws Exception {
+        Ignite ignite = startGrids(1);
+
+        ignite.cluster().state(ACTIVE);
+        IgniteCache<Object, Object> cache = ignite.createCache(DEFAULT_CACHE_NAME);
+
+        for (int i = 0; i < 100_000; i++) {
+            cache.put("key" + i, ThreadLocalRandom.current().nextDouble());
+        }
+
+        assertFalse(G.allGrids().isEmpty());
+    }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
index ed3680c..65f892c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
@@ -58,6 +58,7 @@ import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemor
 import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryLazyAllocationWithPDSTest;
 import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryNoStoreLeakTest;
 import org.apache.ignite.internal.processors.cache.persistence.pagemem.PagesWriteThrottleSmokeTest;
+import org.apache.ignite.internal.processors.cache.persistence.pagemem.SpeedBasedThrottleBreakdownTest;
 import org.apache.ignite.internal.processors.cache.persistence.pagemem.UsedPagesMetricTest;
 import org.apache.ignite.internal.processors.cache.persistence.pagemem.UsedPagesMetricTestPersistence;
 import org.apache.ignite.internal.processors.cache.persistence.tree.io.TrackingPageIOTest;
@@ -122,6 +123,7 @@ public class IgnitePdsTestSuite {
 
         // Write throttling
         GridTestUtils.addTestIfNeeded(suite, PagesWriteThrottleSmokeTest.class, ignoredTests);
+        GridTestUtils.addTestIfNeeded(suite, SpeedBasedThrottleBreakdownTest.class, ignoredTests);
 
         // Discovery data handling on node join and old cluster abnormal shutdown
         GridTestUtils.addTestIfNeeded(suite, IgnitePdsDiscoDataHandlingInNewClusterTest.class, ignoredTests);