You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/01/24 16:37:19 UTC

[ignite] branch ignite-11030-test updated: IGNITE-11030 Fix Pages List to preserve partition ID consistency.

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

dpavlov pushed a commit to branch ignite-11030-test
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/ignite-11030-test by this push:
     new e7468df  IGNITE-11030 Fix Pages List to preserve partition ID consistency.
e7468df is described below

commit e7468dfb1dfbceef5cbe8a99e0cbe3f73e52e6a4
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Thu Jan 24 19:37:11 2019 +0300

    IGNITE-11030 Fix Pages List to preserve partition ID consistency.
---
 .../cache/persistence/freelist/PagesList.java      |  8 ++-
 .../persistence/db/IgniteTcBotInitNewPageTest.java | 80 ++++++++++++++++++++++
 .../persistence/db/IgniteTcBotSandboxTest.java     |  2 +-
 .../testsuites/IgnitePdsWithIndexingTestSuite.java |  4 +-
 4 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/PagesList.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/PagesList.java
index 0358975..4359ef4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/PagesList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/PagesList.java
@@ -1157,9 +1157,11 @@ public abstract class PagesList extends DataStructure {
 
                         decrementBucketSize(bucket);
 
-                        if (initIoVers != null)
-                            dataPageId = initReusedPage(tailId, tailPage, tailAddr, 0, FLAG_DATA, initIoVers.latest());
-                        else
+                        if (initIoVers != null) {
+                            int partId = PageIdUtils.partId(tailId);
+
+                            dataPageId = initReusedPage(tailId, tailPage, tailAddr, partId, FLAG_DATA, initIoVers.latest());
+                        } else
                             dataPageId = recyclePage(tailId, tailPage, tailAddr, null);
 
                         dirty = true;
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteTcBotInitNewPageTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteTcBotInitNewPageTest.java
new file mode 100644
index 0000000..0c248ff
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteTcBotInitNewPageTest.java
@@ -0,0 +1,80 @@
+/*
+* 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.db;
+
+import com.google.common.base.Strings;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.pagemem.wal.record.delta.InitNewPageRecord;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+/**
+ * Test creates a lot of index pages in the cache with low number of partitions.<br>
+ * Then cache entries are removed to enforce all pages to come to a free list. <br>
+ * Then creation of data pages with long data will probably result in page rotation.<br>
+ * Expected behaviour: all {@link InitNewPageRecord} should have consistent partition IDs.
+ */
+public class IgniteTcBotInitNewPageTest extends GridCommonAbstractTest {
+    /** Cache name. */
+    public static final String CACHE = "cache";
+
+    @Test
+    public void testInitNewPagePageIdConsistency() throws Exception {
+        IgniteEx ex = startGrid(0);
+
+        IgniteCache<Object, Object> cache = ex.cache(CACHE);
+
+        for (int i = 0; i < 1_000_000; i++)
+            cache.put(i, i);
+
+        cache.clear();
+
+        for (int i = 0; i < 1_000; i++)
+            cache.put(i, Strings.repeat("Apache Ignite", 1000));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        CacheConfiguration<Integer, Object> ccfg = new CacheConfiguration<>(CACHE);
+
+        ccfg.setAffinity(new RendezvousAffinityFunction(false, 4));
+
+        cfg.setCacheConfiguration(ccfg);
+
+        DataRegionConfiguration regCfg = new DataRegionConfiguration()
+            .setMaxSize(2L * 1024 * 1024 * 1024)
+            .setPersistenceEnabled(true);
+
+        DataStorageConfiguration dsCfg = new DataStorageConfiguration()
+            .setWalMode(WALMode.LOG_ONLY)
+            .setDefaultDataRegionConfiguration(regCfg);
+
+        cfg.setDataStorageConfiguration(dsCfg);
+
+        return cfg;
+    }
+}
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteTcBotSandboxTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteTcBotSandboxTest.java
index 8962fdf..b85e756 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteTcBotSandboxTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteTcBotSandboxTest.java
@@ -154,7 +154,7 @@ public class IgniteTcBotSandboxTest extends GridCommonAbstractTest {
         cfg.setConsistentId("TcHelper");
 
         DataRegionConfiguration regCfg = new DataRegionConfiguration()
-            .setMaxSize(2L * 1024 * 1024 * 1027)
+            .setMaxSize(2L * 1024 * 1024 * 1024)
             .setPersistenceEnabled(true);
 
         DataStorageConfiguration dsCfg = new DataStorageConfiguration()
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
index 41fb55f..3e8de63 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
@@ -19,6 +19,7 @@ package org.apache.ignite.testsuites;
 
 import org.apache.ignite.internal.processors.cache.IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest;
 import org.apache.ignite.internal.processors.cache.IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.IgniteTcBotSandboxTest;
 import org.apache.ignite.internal.processors.database.IgniteDbMultiNodeWithIndexingPutGetTest;
 import org.apache.ignite.internal.processors.database.IgniteDbSingleNodeWithIndexingPutGetTest;
 import org.apache.ignite.internal.processors.database.IgniteDbSingleNodeWithIndexingWalRestoreTest;
@@ -38,7 +39,8 @@ import org.junit.runners.Suite;
     IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.class,
     IgnitePersistentStoreSchemaLoadTest.class,
     IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.class,
-    IgniteTwoRegionsRebuildIndexTest.class
+    IgniteTwoRegionsRebuildIndexTest.class,
+    IgniteTcBotSandboxTest.class
 })
 public class IgnitePdsWithIndexingTestSuite {
 }