ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [39/50] [abbrv] ignite git commit: IGNITE-5901 Fixed AsynchronousCloseException in WAL
Date Mon, 21 Aug 2017 08:40:48 GMT
IGNITE-5901 Fixed AsynchronousCloseException in WAL


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

Branch: refs/heads/ignite-5578
Commit: c15d260fee40e68c90cb99ae4aa643886b3740fe
Parents: 7b9aa08
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Fri Aug 18 12:47:08 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Fri Aug 18 12:47:08 2017 +0300

----------------------------------------------------------------------
 .../wal/FileWriteAheadLogManager.java           | 68 +++++++++++---------
 .../db/wal/IgniteWalRecoveryTest.java           |  2 +
 2 files changed, 41 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c15d260f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index bb1f910..a9327a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -2019,6 +2019,9 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
 
                 flushOrWait(ptr, stop);
 
+                if (stopped())
+                    return;
+
                 if (lastFsyncPos != written) {
                     assert lastFsyncPos < written; // Fsync position must be behind.
 
@@ -2056,51 +2059,58 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
          */
         private boolean close(boolean rollOver) throws IgniteCheckedException, StorageException
{
             if (stop.compareAndSet(false, true)) {
-                flushOrWait(null, true);
-
-                assert stopped() : "Segment is not closed after close flush: " + head.get();
+                lock.lock();
 
                 try {
-                    int switchSegmentRecSize = RecordV1Serializer.REC_TYPE_SIZE + RecordV1Serializer.FILE_WAL_POINTER_SIZE;
+                    flushOrWait(null, true);
+
+                    assert stopped() : "Segment is not closed after close flush: " + head.get();
+
+                    try {
+                        int switchSegmentRecSize = RecordV1Serializer.REC_TYPE_SIZE + RecordV1Serializer.FILE_WAL_POINTER_SIZE;
 
-                    if (rollOver && written < (maxSegmentSize - switchSegmentRecSize))
{
-                        //it is expected there is sufficient space for this record because
rollover should run early
-                        final ByteBuffer buf = ByteBuffer.allocate(switchSegmentRecSize);
-                        buf.put((byte)(WALRecord.RecordType.SWITCH_SEGMENT_RECORD.ordinal()
+ 1));
+                        if (rollOver && written < (maxSegmentSize - switchSegmentRecSize))
{
+                            //it is expected there is sufficient space for this record because
rollover should run early
+                            final ByteBuffer buf = ByteBuffer.allocate(switchSegmentRecSize);
+                            buf.put((byte)(WALRecord.RecordType.SWITCH_SEGMENT_RECORD.ordinal()
+ 1));
 
-                        final FileWALPointer pointer = new FileWALPointer(idx, (int)fileIO.position(),
-1);
-                        RecordV1Serializer.putPosition(buf, pointer);
+                            final FileWALPointer pointer = new FileWALPointer(idx, (int)fileIO.position(),
-1);
+                            RecordV1Serializer.putPosition(buf, pointer);
 
-                        buf.rewind();
+                            buf.rewind();
 
-                        int rem = buf.remaining();
+                            int rem = buf.remaining();
 
-                        while (rem > 0) {
-                            int written0 = fileIO.write(buf, written);
+                            while (rem > 0) {
+                                int written0 = fileIO.write(buf, written);
 
-                            written += written0;
+                                written += written0;
 
-                            rem -= written0;
+                                rem -= written0;
+                            }
                         }
-                    }
 
-                    // Do the final fsync.
-                    if (mode == WALMode.DEFAULT) {
-                        fileIO.force();
+                        // Do the final fsync.
+                        if (mode == WALMode.DEFAULT) {
+                            fileIO.force();
 
-                        lastFsyncPos = written;
+                            lastFsyncPos = written;
+                        }
+
+                        fileIO.close();
                     }
+                    catch (IOException e) {
+                        throw new IgniteCheckedException(e);
+                    }
+
+                    if (log.isDebugEnabled())
+                        log.debug("Closed WAL write handle [idx=" + idx + "]");
 
-                    fileIO.close();
+                    return true;
                 }
-                catch (IOException e) {
-                    throw new IgniteCheckedException(e);
+                finally {
+                    lock.unlock();
                 }
-
-                if (log.isDebugEnabled())
-                    log.debug("Closed WAL write handle [idx=" + idx + "]");
-
-                return true;
             }
             else
                 return false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/c15d260f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
index c5d6a8b..399e36d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
@@ -138,6 +138,8 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest {
 
         pCfg.setWalRecordIteratorBufferSize(1024 * 1024);
 
+        pCfg.setWalHistorySize(2);
+
         if (logOnly)
             pCfg.setWalMode(WALMode.LOG_ONLY);
 


Mime
View raw message