You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2020/01/31 15:00:31 UTC

[ignite] branch master updated: IGNITE-12612 Fix broken test, H2TreeIndex#destroy and H2TreeIndex#asyncDestroy refactoring - Fixes #7343.

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

agoncharuk 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 842923d  IGNITE-12612 Fix broken test, H2TreeIndex#destroy and H2TreeIndex#asyncDestroy refactoring - Fixes #7343.
842923d is described below

commit 842923d45fac17be971018ee686c2fd43af6917e
Author: denis-chudov <dc...@gridgain.com>
AuthorDate: Fri Jan 31 17:58:53 2020 +0300

    IGNITE-12612 Fix broken test, H2TreeIndex#destroy and H2TreeIndex#asyncDestroy refactoring - Fixes #7343.
    
    Signed-off-by: Alexey Goncharuk <al...@gmail.com>
---
 .../processors/query/h2/database/H2TreeIndex.java  | 65 +++++++++++-----------
 1 file changed, 31 insertions(+), 34 deletions(-)

diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
index 01f4af1..0498a24 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
@@ -533,32 +533,21 @@ public class H2TreeIndex extends H2TreeIndexBase {
 
     /** {@inheritDoc} */
     @Override public void destroy(boolean rmvIdx) {
-        try {
-            if (cctx.affinityNode() && rmvIdx) {
-                assert cctx.shared().database().checkpointLockIsHeldByThread();
-
-                for (int i = 0; i < segments.length; i++) {
-                    H2Tree tree = segments[i];
-
-                    tree.destroy();
-
-                    dropMetaPage(i);
-                }
-
-                ctx.metric().remove(stats.metricRegistryName());
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw new IgniteException(e);
-        }
-        finally {
-            if (msgLsnr != null)
-                ctx.io().removeMessageListener(msgTopic, msgLsnr);
-        }
+        destroy0(rmvIdx, false);
     }
 
     /** {@inheritDoc} */
     @Override public void asyncDestroy(boolean rmvIdx) {
+        destroy0(rmvIdx, true);
+    }
+
+    /**
+     * Internal method for destroying index with async option.
+     *
+     * @param rmvIdx Flag remove.
+     * @param async Destroy asynchronously.
+     */
+    private void destroy0(boolean rmvIdx, boolean async) {
         try {
             if (cctx.affinityNode() && rmvIdx) {
                 assert cctx.shared().database().checkpointLockIsHeldByThread();
@@ -569,24 +558,32 @@ public class H2TreeIndex extends H2TreeIndexBase {
                 for (int i = 0; i < segments.length; i++) {
                     H2Tree tree = segments[i];
 
-                    tree.markDestroyed();
+                    if (async) {
+                        tree.markDestroyed();
 
-                    rootPages.add(tree.getMetaPageId());
-                    trees.add(tree);
+                        rootPages.add(tree.getMetaPageId());
+                        trees.add(tree);
+                    }
+                    else
+                        tree.destroy();
 
                     dropMetaPage(i);
                 }
 
-                DurableBackgroundTask task = new DurableBackgroundCleanupIndexTreeTask(
-                    rootPages,
-                    trees,
-                    cctx.group().name(),
-                    cctx.cache().name(),
-                    table.getSchema().getName(),
-                    idxName
-                );
+                ctx.metric().remove(stats.metricRegistryName());
 
-                cctx.kernalContext().durableBackgroundTasksProcessor().startDurableBackgroundTask(task, cctx.config());
+                if (async) {
+                    DurableBackgroundTask task = new DurableBackgroundCleanupIndexTreeTask(
+                        rootPages,
+                        trees,
+                        cctx.group().name(),
+                        cctx.cache().name(),
+                        table.getSchema().getName(),
+                        idxName
+                    );
+
+                    cctx.kernalContext().durableBackgroundTasksProcessor().startDurableBackgroundTask(task, cctx.config());
+                }
             }
         }
         catch (IgniteCheckedException e) {