You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ti...@apache.org on 2021/11/29 14:48:53 UTC

[ignite] 01/01: WIP

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

timoninmaxim pushed a commit to branch IGNITE-15621__flaky_idx_qry
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit dee165516555ab57d8b6272c74ee04cedfb2e37d
Author: Maksim Timonin <ti...@gmail.com>
AuthorDate: Mon Nov 29 17:39:07 2021 +0300

    WIP
---
 .../query/index/sorted/inline/InlineIndexImpl.java |  8 +++++
 .../cache/query/MultifieldIndexQueryTest.java      | 41 +++++++++++++++++++---
 2 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/InlineIndexImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/InlineIndexImpl.java
index 7bf3fc4..f321eb6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/InlineIndexImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/InlineIndexImpl.java
@@ -228,6 +228,14 @@ public class InlineIndexImpl extends AbstractIndex implements InlineIndex {
     @Override public void onUpdate(@Nullable CacheDataRow oldRow, @Nullable CacheDataRow newRow,
         boolean prevRowAvailable) throws IgniteCheckedException {
         try {
+            try {
+                if (cctx.kernalContext().hasNodeAttribute("FAIL"))
+                    Thread.sleep(100);
+            }
+            catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+
             if (destroyed.get())
                 return;
 
diff --git a/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultifieldIndexQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultifieldIndexQueryTest.java
index 3064414..c04052f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultifieldIndexQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultifieldIndexQueryTest.java
@@ -32,9 +32,11 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.junit.Test;
@@ -97,7 +99,9 @@ public class MultifieldIndexQueryTest extends GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        ignite = startGrids(nodesCnt);
+        ignite = startGrids(1);
+
+        grid(0).context().addNodeAttribute("FAIL", "FAIL");
 
         cache = ignite.cache(CACHE);
     }
@@ -113,9 +117,11 @@ public class MultifieldIndexQueryTest extends GridCommonAbstractTest {
 
         CacheConfiguration<?, ?> ccfg = new CacheConfiguration<>()
             .setName(CACHE)
-            .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
             .setIndexedTypes(Long.class, Person.class)
-            .setQueryParallelism(4);
+//            .setQueryParallelism(4)
+            .setAtomicityMode(CacheAtomicityMode.ATOMIC)
+            .setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC)
+            .setBackups(0);
 
         cfg.setCacheConfiguration(ccfg);
 
@@ -154,7 +160,32 @@ public class MultifieldIndexQueryTest extends GridCommonAbstractTest {
 
     /** */
     @Test
+    public void test() {
+        for (int j = 0; j < 10; j++) {
+            for (int i = 0; i < 20; i++)
+                cache.put((long)(j * 100 + i), new Person(j, 1));
+        }
+
+        IndexQuery<Long, Person> qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
+            .setCriteria(between("id", 2, 8));
+
+        List<Cache.Entry<Long, Person>> result = cache.query(qry).getAll();
+
+        assertEquals(2, result.size());
+    }
+
+    /** */
+    @Test
     public void testCheckBoundaries() {
+//        cache.putAll(F.asMap(
+//            1L, new Person(0, 1),
+//            2L, new Person(1, 0),
+//            3L, new Person(1, 1)
+////            4L, new Person(10, 10),
+////            5L, new Person(100, 100)
+////            6L, new Person(32, 143)
+//        ));
+
         cache.put(1L, new Person(0, 1));
         cache.put(2L, new Person(1, 0));
         cache.put(3L, new Person(1, 1));
@@ -501,8 +532,8 @@ public class MultifieldIndexQueryTest extends GridCommonAbstractTest {
         /** */
         @QuerySqlField(orderedGroups = {
             @QuerySqlField.Group(name = INDEX, order = 0),
-            @QuerySqlField.Group(name = DESC_INDEX, order = 0)}
-        )
+            @QuerySqlField.Group(name = DESC_INDEX, order = 0)
+        })
         final int id;
 
         /** */