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/09 16:13:10 UTC
ignite git commit: IGNITE-9822 Corrected WAL archiver thread stop
logic - Fixes #4930.
Repository: ignite
Updated Branches:
refs/heads/master 35b7a3c05 -> c7d6f110f
IGNITE-9822 Corrected WAL archiver thread stop logic - Fixes #4930.
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/c7d6f110
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c7d6f110
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c7d6f110
Branch: refs/heads/master
Commit: c7d6f110fc39749307e3f8ce203beb5f72f40994
Parents: 35b7a3c
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Oct 9 19:10:14 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Oct 9 19:12:14 2018 +0300
----------------------------------------------------------------------
.../wal/FileWriteAheadLogManager.java | 28 +++++++++++---------
.../wal/FsyncModeFileWriteAheadLogManager.java | 23 +++++++---------
2 files changed, 25 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7d6f110/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 28d9b07..b4ce0f1 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
@@ -1642,19 +1642,18 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
* the absolute index of last archived segment is denoted by A and the absolute index of next segment we want to
* write is denoted by W, then we can allow write to S(W) if W - A <= walSegments. <br>
*
- * Monitor of current object is used for notify on: <ul> <li>exception occurred ({@link
- * FileArchiver#cleanErr}!=null)</li> <li>stopping thread ({@link FileArchiver#stopped}==true)</li> <li>current file
- * index changed </li> <li>last archived file index was changed ({@link
- * </li> <li>some WAL index was removed from map</li>
+ * Monitor of current object is used for notify on: <ul>
+ * <li>exception occurred ({@link FileArchiver#cleanErr}!=null)</li>
+ * <li>stopping thread ({@link FileArchiver#isCancelled==true})</li>
+ * <li>current file index changed </li>
+ * <li>last archived file index was changed</li>
+ * <li>some WAL index was removed from map</li>
* </ul>
*/
private class FileArchiver extends GridWorker {
/** Exception which occurred during initial creation of files or during archiving WAL segment */
private StorageException cleanErr;
- /** current thread stopping advice */
- private volatile boolean stopped;
-
/** Formatted index. */
private int formatted;
@@ -1673,7 +1672,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
*/
private void shutdown() throws IgniteInterruptedCheckedException {
synchronized (this) {
- stopped = true;
+ isCancelled = true;
notifyAll();
}
@@ -1710,13 +1709,15 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
try {
blockingSectionBegin();
+
try {
segmentAware.awaitSegment(0);//wait for init at least one work segments.
}
finally {
blockingSectionEnd();
}
- while (!Thread.currentThread().isInterrupted() && !stopped) {
+
+ while (!Thread.currentThread().isInterrupted() && !isCancelled()) {
long toArchive;
blockingSectionBegin();
@@ -1727,7 +1728,8 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
finally {
blockingSectionEnd();
}
- if (stopped)
+
+ if (isCancelled())
break;
SegmentArchiveResult res;
@@ -1765,14 +1767,14 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
Thread.currentThread().interrupt();
synchronized (this) {
- stopped = true;
+ isCancelled = true;
}
}
catch (Throwable t) {
err = t;
}
finally {
- if (err == null && !stopped)
+ if (err == null && !isCancelled())
err = new IllegalStateException("Worker " + name() + " is terminated unexpectedly");
if (err instanceof OutOfMemoryError)
@@ -1886,7 +1888,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
*
*/
private boolean checkStop() {
- return stopped;
+ return isCancelled();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/c7d6f110/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 3d1b0e0..fc1461a 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
@@ -1428,7 +1428,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
* Monitor of current object is used for notify on:
* <ul>
* <li>exception occurred ({@link FileArchiver#cleanException}!=null)</li>
- * <li>stopping thread ({@link FileArchiver#stopped}==true)</li>
+ * <li>stopping thread ({@link FileArchiver#isCancelled}==true)</li>
* <li>current file index changed ({@link FileArchiver#curAbsWalIdx})</li>
* <li>last archived file index was changed ({@link FileArchiver#lastAbsArchivedIdx})</li>
* <li>some WAL index was removed from {@link FileArchiver#locked} map</li>
@@ -1447,9 +1447,6 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
/** Last archived file index (absolute, 0-based). Guarded by <code>this</code>. */
private volatile long lastAbsArchivedIdx = -1;
- /** current thread stopping advice */
- private volatile boolean stopped;
-
/** */
private NavigableMap<Long, Integer> reserved = new TreeMap<>();
@@ -1484,7 +1481,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
*/
private void shutdown() throws IgniteInterruptedCheckedException {
synchronized (this) {
- stopped = true;
+ isCancelled = true;
notifyAll();
}
@@ -1566,7 +1563,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
try {
synchronized (this) {
- while (curAbsWalIdx == -1 && !stopped) {
+ while (curAbsWalIdx == -1 && !isCancelled()) {
blockingSectionBegin();
try {
@@ -1582,14 +1579,14 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
// once it was archived.
}
- while (!Thread.currentThread().isInterrupted() && !stopped) {
+ while (!Thread.currentThread().isInterrupted() && !isCancelled()) {
long toArchive;
synchronized (this) {
assert lastAbsArchivedIdx <= curAbsWalIdx : "lastArchived=" + lastAbsArchivedIdx +
", current=" + curAbsWalIdx;
- while (lastAbsArchivedIdx >= curAbsWalIdx - 1 && !stopped) {
+ while (lastAbsArchivedIdx >= curAbsWalIdx - 1 && !isCancelled()) {
blockingSectionBegin();
try {
@@ -1603,7 +1600,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
toArchive = lastAbsArchivedIdx + 1;
}
- if (stopped)
+ if (isCancelled())
break;
SegmentArchiveResult res;
@@ -1618,7 +1615,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
}
synchronized (this) {
- while (locked.containsKey(toArchive) && !stopped) {
+ while (locked.containsKey(toArchive) && !isCancelled()) {
blockingSectionBegin();
try {
@@ -1645,14 +1642,14 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
catch (InterruptedException t) {
Thread.currentThread().interrupt();
- if (!stopped)
+ if (!isCancelled())
err = t;
}
catch (Throwable t) {
err = t;
}
finally {
- if (err == null && !stopped)
+ if (err == null && !isCancelled())
err = new IllegalStateException("Worker " + name() + " is terminated unexpectedly");
if (err instanceof OutOfMemoryError)
@@ -1827,7 +1824,7 @@ public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAda
*
*/
private boolean checkStop() {
- return stopped;
+ return isCancelled();
}
/**