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 2018/10/19 09:16:19 UTC

ignite git commit: IGNITE-9776 Fixed infinite block in FsyncModeFileWriteAheadLogManager log() call - Fixes #4953.

Repository: ignite
Updated Branches:
  refs/heads/master 5427c098b -> 7deec60a8


IGNITE-9776 Fixed infinite block in FsyncModeFileWriteAheadLogManager log() call - Fixes #4953.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7deec60a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7deec60a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7deec60a

Branch: refs/heads/master
Commit: 7deec60a8727d86fe153962979c3c9f4d67d8e09
Parents: 5427c09
Author: Alexey Stelmak <sp...@gmail.com>
Authored: Fri Oct 19 12:11:32 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Oct 19 12:15:48 2018 +0300

----------------------------------------------------------------------
 .../wal/FsyncModeFileWriteAheadLogManager.java  | 27 ++++--
 .../wal/FsyncWalRolloverDoesNotBlockTest.java   | 89 ++++++++++++++++++++
 .../db/wal/WalRolloverTypesTest.java            |  8 --
 .../ignite/testsuites/IgnitePdsTestSuite2.java  |  3 +
 .../testsuites/IgnitePdsNativeIoTestSuite2.java |  1 +
 5 files changed, 112 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7deec60a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java
index 917640d..0ede897 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java
@@ -419,9 +419,9 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
 
             lastTruncatedArchiveIdx = tup == null ? -1 : tup.get1() - 1;
 
-            archiver = new FileArchiver(tup == null ? -1 : tup.get2(), log);
+            archiver = isArchiverEnabled() ? new FileArchiver(tup == null ? -1 : tup.get2(), log) : null;
 
-            if (dsCfg.isWalCompactionEnabled()) {
+            if (archiver != null && dsCfg.isWalCompactionEnabled()) {
                 compressor = new FileCompressor();
 
                 if (decompressor == null) {  // Preventing of two file-decompressor thread instantiations.
@@ -619,7 +619,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
     public Collection<File> getAndReserveWalFiles(FileWALPointer low, FileWALPointer high) throws IgniteCheckedException {
         final long awaitIdx = high.index() - 1;
 
-        while (archiver.lastArchivedAbsoluteIndex() < awaitIdx)
+        while (archiver != null && archiver.lastArchivedAbsoluteIndex() < awaitIdx)
             LockSupport.parkNanos(Thread.currentThread(), 1_000_000);
 
         if (!reserve(low))
@@ -918,6 +918,9 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
 
     /** {@inheritDoc} */
     @Override public int walArchiveSegments() {
+        if (archiver == null)
+            return 0;
+
         long lastTruncated = lastTruncatedArchiveIdx;
 
         long lastArchived = archiver.lastArchivedAbsoluteIndex();
@@ -966,7 +969,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
 
     /** {@inheritDoc} */
     @Override public long lastArchivedSegment() {
-        return archiver.lastArchivedAbsoluteIndex();
+        return archiver != null ? archiver.lastArchivedAbsoluteIndex() : -1L;
     }
 
     /** {@inheritDoc} */
@@ -1235,7 +1238,8 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
                 if (lastReadPtr == null)
                     hnd.writeSerializerVersion();
 
-                archiver.currentWalIndex(absIdx);
+                if (archiver != null)
+                    archiver.currentWalIndex(absIdx);
 
                 return hnd;
             }
@@ -1411,8 +1415,13 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
      * @throws IgniteInterruptedCheckedException If interrupted.
      */
     private File pollNextFile(long curIdx) throws StorageException, IgniteInterruptedCheckedException {
+        FileArchiver archiver0 = archiver;
+
+        if (archiver0 == null)
+            return new File(walWorkDir, FileDescriptor.fileName(curIdx + 1));
+
         // Signal to archiver that we are done with the segment and it can be archived.
-        long absNextIdx = archiver.nextAbsoluteSegmentIndex(curIdx);
+        long absNextIdx = archiver0.nextAbsoluteSegmentIndex(curIdx);
 
         long segmentIdx = absNextIdx % dsCfg.getWalSegments();
 
@@ -1724,8 +1733,10 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
 
                     int segments = dsCfg.getWalSegments();
 
-                    while ((curAbsWalIdx - lastAbsArchivedIdx > segments && cleanException == null))
-                        wait();
+                    if (isArchiverEnabled()) {
+                        while ((curAbsWalIdx - lastAbsArchivedIdx > segments && cleanException == null))
+                            wait();
+                    }
 
                     if (cleanException != null)
                         throw cleanException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7deec60a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/FsyncWalRolloverDoesNotBlockTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/FsyncWalRolloverDoesNotBlockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/FsyncWalRolloverDoesNotBlockTest.java
new file mode 100644
index 0000000..aa2e90c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/FsyncWalRolloverDoesNotBlockTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.wal;
+
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH;
+import static org.apache.ignite.configuration.WALMode.FSYNC;
+
+/** */
+public class FsyncWalRolloverDoesNotBlockTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static class RolloverRecord extends CheckpointRecord {
+        /** */
+        private RolloverRecord() {
+            super(null);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String name) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(name);
+
+        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true))
+            .setWalMode(FSYNC)
+            .setWalArchivePath(DFLT_WAL_PATH));
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        stopAllGrids();
+
+        cleanPersistenceDir();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        cleanPersistenceDir();
+    }
+
+    /** */
+    public void test() throws Exception {
+        IgniteEx ig = startGrid(0);
+
+        ig.cluster().active(true);
+
+        ig.context().cache().context().database().checkpointReadLock();
+
+        try {
+            ig.context().cache().context().wal().log(new RolloverRecord());
+        }
+        finally {
+            ig.context().cache().context().database().checkpointReadUnlock();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/7deec60a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverTypesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverTypesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverTypesTest.java
index 122ecb6..db56cd2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverTypesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverTypesTest.java
@@ -117,8 +117,6 @@ public class WalRolloverTypesTest extends GridCommonAbstractTest {
 
     /** */
     public void testCurrentSegmentTypeLogFsyncModeArchiveOff() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-9776");
-
         checkCurrentSegmentType(FSYNC, true);
     }
 
@@ -139,8 +137,6 @@ public class WalRolloverTypesTest extends GridCommonAbstractTest {
 
     /** */
     public void testNextSegmentTypeFsyncModeArchiveOff() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-9776");
-
         checkNextSegmentType(FSYNC, true);
     }
 
@@ -207,8 +203,6 @@ public class WalRolloverTypesTest extends GridCommonAbstractTest {
 
     /** */
     public void testNextSegmentTypeWithCacheActivityFsyncModeArchiveOff() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-9776");
-
         checkNextSegmentTypeWithCacheActivity(FSYNC, true);
     }
 
@@ -295,8 +289,6 @@ public class WalRolloverTypesTest extends GridCommonAbstractTest {
 
     /** */
     public void testCurrentSegmentTypeWithCacheActivityFsyncModeArchiveOff() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-9776");
-
         checkCurrentSegmentTypeWithCacheActivity(FSYNC, true);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7deec60a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
index ede5cab..75a8af7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
@@ -39,6 +39,7 @@ import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsWhole
 import org.apache.ignite.internal.processors.cache.persistence.db.SlowHistoricalRebalanceSmallHistoryTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.IgniteCheckpointDirtyPagesForLowLoadTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.filename.IgniteUidAsConsistentIdMigrationTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.wal.FsyncWalRolloverDoesNotBlockTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteNodeStoppedDuringDisableWALTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWALTailIsReachedDuringIterationOverArchiveTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalFlushBackgroundSelfTest;
@@ -191,5 +192,7 @@ public class IgnitePdsTestSuite2 extends TestSuite {
         suite.addTestSuite(IgniteWALTailIsReachedDuringIterationOverArchiveTest.class);
 
         suite.addTestSuite(WalRolloverTypesTest.class);
+
+        suite.addTestSuite(FsyncWalRolloverDoesNotBlockTest.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7deec60a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java
index 2ed7450..7aebe95 100644
--- a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java
+++ b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java
@@ -19,6 +19,7 @@ package org.apache.ignite.testsuites;
 import junit.framework.TestSuite;
 import org.apache.ignite.internal.processors.cache.persistence.IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest;
 import org.apache.ignite.internal.processors.cache.persistence.IgniteNativeIoPdsRecoveryAfterFileCorruptionTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.wal.FsyncWalRolloverDoesNotBlockTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteNativeIoWalFlushFsyncSelfTest;
 
 /**