You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/05/21 08:46:12 UTC

[GitHub] [ignite] Mmuzaf opened a new pull request #7827: IGNITE-12978: add cancel snapshot support

Mmuzaf opened a new pull request #7827:
URL: https://github.com/apache/ignite/pull/7827


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-12407: Add Cluster API support to Java thin client`
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Mmuzaf merged pull request #7827: IGNITE-12978: add cancel snapshot support

Posted by GitBox <gi...@apache.org>.
Mmuzaf merged pull request #7827:
URL: https://github.com/apache/ignite/pull/7827


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] NSAmelchev commented on a change in pull request #7827: IGNITE-12978: add cancel snapshot support

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on a change in pull request #7827:
URL: https://github.com/apache/ignite/pull/7827#discussion_r429582705



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -540,10 +542,14 @@ private void processLocalSnapshotStartStageResult(UUID id, Map<UUID, SnapshotOpe
             missed.removeAll(res.keySet());
             missed.removeAll(err.keySet());
 
-            snpReq.hasErr = !F.isEmpty(err) || !missed.isEmpty();
+            boolean cancelled = err.values().stream()
+                .anyMatch(e -> e instanceof IgniteFutureCancelledCheckedException);

Review comment:
       Can be in one line

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -540,10 +542,14 @@ private void processLocalSnapshotStartStageResult(UUID id, Map<UUID, SnapshotOpe
             missed.removeAll(res.keySet());
             missed.removeAll(err.keySet());
 
-            snpReq.hasErr = !F.isEmpty(err) || !missed.isEmpty();
+            boolean cancelled = err.values().stream()
+                .anyMatch(e -> e instanceof IgniteFutureCancelledCheckedException);
 
-            if (snpReq.hasErr) {
-                U.warn(log, "Execution of local snapshot tasks fails or them haven't been executed " +
+            if (cancelled) {
+                snpReq.err = new IgniteFutureCancelledCheckedException("Execution of snapshot tasks " +
+                    "has been cancelled by external process [err=" + err + ", missed=" + missed + ']');
+            } else if (!F.isEmpty(err) || !missed.isEmpty()) {

Review comment:
       `else` should be on a new line.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java
##########
@@ -627,7 +629,7 @@ private Runnable wrapExceptionIfStarted(IgniteThrowableRunner exec) {
 
     /** {@inheritDoc} */
     @Override public boolean cancel() {
-        acceptException(new IgniteCheckedException("Snapshot operation has been cancelled by external process " +
+        acceptException(new IgniteFutureCancelledCheckedException("Snapshot operation has been cancelled by external process " +

Review comment:
       Too long line

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -634,6 +642,66 @@ public boolean isSnapshotCreating() {
         }
     }
 
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> cancelSnapshot(String name) {
+        A.notNullOrEmpty(name, "Snapshot name must be not empty or null");
+
+        IgniteInternalFuture<Void> fut0 = cctx.kernalContext().closure()
+            .broadcast(new CancelSnapshotClosure(),

Review comment:
       Suppose that next processes in the cluster will happen simultaneously:
   1. The `END_SNAPSHOT` DP will be at the finish stage and only part of nodes processed their 'this::processLocalSnapshotEndStageResult'
   2. Part of nodes executes broadcasted closure `cancelLocalSnapshotTask`
   
   They are processed by different threads. Can we get a situation when part of nodes finish `clusterSnpFut` successfully and other ones with error? It's ok?

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotCancelTask.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.visor.snapshot;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSnapshot;
+import org.apache.ignite.internal.commandline.snapshot.SnapshotCommand;
+import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotMXBeanImpl;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+
+/**
+ * @see SnapshotCommand
+ * @see IgniteSnapshot#cancelSnapshot(String)
+ */
+@GridInternal
+public class VisorSnapshotCancelTask extends VisorOneNodeTask<String, String> {
+    /** Serial version uid. */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<String, String> job(String arg) {
+        return new VisorSnapshotCancelJob(arg, debug);
+    }
+
+    /** */
+    private static class VisorSnapshotCancelJob extends VisorJob<String, String> {
+        /** Serial version uid. */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param name Snapshot name.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSnapshotCancelJob(String name, boolean debug) {
+            super(name, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected String run(String name) throws IgniteException {
+            new SnapshotMXBeanImpl(ignite.context()).cancelSnapshot(name);
+
+            return "Snapshot operation cancelled.";

Review comment:
       Can we print `The cancel command has no effect. Snapshot already created.`  if cancel will have no effect?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Mmuzaf commented on a change in pull request #7827: IGNITE-12978: add cancel snapshot support

Posted by GitBox <gi...@apache.org>.
Mmuzaf commented on a change in pull request #7827:
URL: https://github.com/apache/ignite/pull/7827#discussion_r429626716



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -634,6 +642,66 @@ public boolean isSnapshotCreating() {
         }
     }
 
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> cancelSnapshot(String name) {
+        A.notNullOrEmpty(name, "Snapshot name must be not empty or null");
+
+        IgniteInternalFuture<Void> fut0 = cctx.kernalContext().closure()
+            .broadcast(new CancelSnapshotClosure(),

Review comment:
       Nikita,
   
   1. It's true that some operations may execute concurrently on snapshot cancellation operation. 
   Snapshot operation consists of four stages:
   - start-stage 
   - start-stage result
   - end-stage
   - end-stage result
   
   If cancel operation occurred when on start-stage than snapshot operation will be canceled. On other stages, it will have no effect since all the cache data already collected.
   
   2. `clusterSnpFut` is set on coordinator only, so it has no effect in case described by you. If some of the local snapshot tasks finish with an error an the other with `CancelledException` than all results will be finished with `CancelledException` (all intermediate results will be deleted).




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] NSAmelchev commented on a change in pull request #7827: IGNITE-12978: add cancel snapshot support

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on a change in pull request #7827:
URL: https://github.com/apache/ignite/pull/7827#discussion_r429670962



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -634,6 +642,66 @@ public boolean isSnapshotCreating() {
         }
     }
 
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> cancelSnapshot(String name) {
+        A.notNullOrEmpty(name, "Snapshot name must be not empty or null");
+
+        IgniteInternalFuture<Void> fut0 = cctx.kernalContext().closure()
+            .broadcast(new CancelSnapshotClosure(),

Review comment:
       Ok, got it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Mmuzaf commented on a change in pull request #7827: IGNITE-12978: add cancel snapshot support

Posted by GitBox <gi...@apache.org>.
Mmuzaf commented on a change in pull request #7827:
URL: https://github.com/apache/ignite/pull/7827#discussion_r429617961



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java
##########
@@ -627,7 +629,7 @@ private Runnable wrapExceptionIfStarted(IgniteThrowableRunner exec) {
 
     /** {@inheritDoc} */
     @Override public boolean cancel() {
-        acceptException(new IgniteCheckedException("Snapshot operation has been cancelled by external process " +
+        acceptException(new IgniteFutureCancelledCheckedException("Snapshot operation has been cancelled by external process " +

Review comment:
       Fixed.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -540,10 +542,14 @@ private void processLocalSnapshotStartStageResult(UUID id, Map<UUID, SnapshotOpe
             missed.removeAll(res.keySet());
             missed.removeAll(err.keySet());
 
-            snpReq.hasErr = !F.isEmpty(err) || !missed.isEmpty();
+            boolean cancelled = err.values().stream()
+                .anyMatch(e -> e instanceof IgniteFutureCancelledCheckedException);

Review comment:
       Fixed.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -540,10 +542,14 @@ private void processLocalSnapshotStartStageResult(UUID id, Map<UUID, SnapshotOpe
             missed.removeAll(res.keySet());
             missed.removeAll(err.keySet());
 
-            snpReq.hasErr = !F.isEmpty(err) || !missed.isEmpty();
+            boolean cancelled = err.values().stream()
+                .anyMatch(e -> e instanceof IgniteFutureCancelledCheckedException);
 
-            if (snpReq.hasErr) {
-                U.warn(log, "Execution of local snapshot tasks fails or them haven't been executed " +
+            if (cancelled) {
+                snpReq.err = new IgniteFutureCancelledCheckedException("Execution of snapshot tasks " +
+                    "has been cancelled by external process [err=" + err + ", missed=" + missed + ']');
+            } else if (!F.isEmpty(err) || !missed.isEmpty()) {

Review comment:
       Fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] NSAmelchev commented on a change in pull request #7827: IGNITE-12978: add cancel snapshot support

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on a change in pull request #7827:
URL: https://github.com/apache/ignite/pull/7827#discussion_r429583927



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotCancelTask.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.visor.snapshot;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSnapshot;
+import org.apache.ignite.internal.commandline.snapshot.SnapshotCommand;
+import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotMXBeanImpl;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+
+/**
+ * @see SnapshotCommand
+ * @see IgniteSnapshot#cancelSnapshot(String)
+ */
+@GridInternal
+public class VisorSnapshotCancelTask extends VisorOneNodeTask<String, String> {
+    /** Serial version uid. */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<String, String> job(String arg) {
+        return new VisorSnapshotCancelJob(arg, debug);
+    }
+
+    /** */
+    private static class VisorSnapshotCancelJob extends VisorJob<String, String> {
+        /** Serial version uid. */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param name Snapshot name.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSnapshotCancelJob(String name, boolean debug) {
+            super(name, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected String run(String name) throws IgniteException {
+            new SnapshotMXBeanImpl(ignite.context()).cancelSnapshot(name);
+
+            return "Snapshot operation cancelled.";

Review comment:
       Can we print `The cancel command has no effect. Snapshot already created.`  if cancel will have no effect?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org