Repository: ignite Updated Branches: refs/heads/ignite-2.7 8a85823b5 -> 054c9becd
IGNITE-9776 Fixed infinite block in FsyncModeFileWriteAheadLogManager log() call - Fixes #4953. Signed-off-by: Alexey Goncharuk <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/054c9bec Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/054c9bec Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/054c9bec Branch: refs/heads/ignite-2.7 Commit: 054c9becd5f48180a2254b52bc9404fdc351f176 Parents: 8a85823 Author: Alexey Stelmak <[email protected]> Authored: Fri Oct 19 12:11:32 2018 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Fri Oct 19 12:25:36 2018 +0300 ---------------------------------------------------------------------- .../wal/FsyncModeFileWriteAheadLogManager.java | 27 ++++-- .../wal/FsyncWalRolloverDoesNotBlockTest.java | 89 ++++++++++++++++++++ .../ignite/testsuites/IgnitePdsTestSuite2.java | 3 + .../testsuites/IgnitePdsNativeIoTestSuite2.java | 4 + 4 files changed, 115 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/054c9bec/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 cfe1ad3..c141574 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 @@ -417,9 +417,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. @@ -617,7 +617,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)) @@ -895,6 +895,9 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda /** {@inheritDoc} */ @Override public int walArchiveSegments() { + if (archiver == null) + return 0; + long lastTruncated = lastTruncatedArchiveIdx; long lastArchived = archiver.lastArchivedAbsoluteIndex(); @@ -943,7 +946,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda /** {@inheritDoc} */ @Override public long lastArchivedSegment() { - return archiver.lastArchivedAbsoluteIndex(); + return archiver != null ? archiver.lastArchivedAbsoluteIndex() : -1L; } /** {@inheritDoc} */ @@ -1205,7 +1208,8 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda if (lastReadPtr == null) hnd.writeSerializerVersion(); - archiver.currentWalIndex(absIdx); + if (archiver != null) + archiver.currentWalIndex(absIdx); return hnd; } @@ -1381,8 +1385,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(); @@ -1694,8 +1703,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/054c9bec/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/054c9bec/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 a9f2601..527a044 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 @@ -38,6 +38,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; @@ -184,5 +185,7 @@ public class IgnitePdsTestSuite2 extends TestSuite { suite.addTestSuite(IgniteRebalanceScheduleResendPartitionsTest.class); suite.addTestSuite(IgniteWALTailIsReachedDuringIterationOverArchiveTest.class); + + suite.addTestSuite(FsyncWalRolloverDoesNotBlockTest.class); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/054c9bec/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..4c1305d 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 @@ -14,11 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + 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; /** @@ -41,6 +43,8 @@ public class IgnitePdsNativeIoTestSuite2 extends TestSuite { suite.addTestSuite(IgniteNativeIoWalFlushFsyncSelfTest.class); + suite.addTestSuite(FsyncWalRolloverDoesNotBlockTest.class); + return suite; } }
