You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/10/07 16:06:01 UTC
activemq-artemis git commit: NO-JIRA: Fixing the testsuite on
Page.finalize()
Repository: activemq-artemis
Updated Branches:
refs/heads/master e1a87ac83 -> 30ba65a08
NO-JIRA: Fixing the testsuite on Page.finalize()
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/30ba65a0
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/30ba65a0
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/30ba65a0
Branch: refs/heads/master
Commit: 30ba65a082eaa6cc3de86a312ae0209d52b64122
Parents: e1a87ac
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Oct 6 16:53:55 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Sat Oct 7 12:05:55 2017 -0400
----------------------------------------------------------------------
.../jdbc/store/file/JDBCSequentialFile.java | 10 +++-
.../artemis/core/io/SequentialFile.java | 8 +++
.../artemis/core/io/aio/AIOSequentialFile.java | 51 ++++++++++++--------
.../core/io/mapped/MappedSequentialFile.java | 5 ++
.../activemq/artemis/core/paging/impl/Page.java | 2 +-
5 files changed, 53 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30ba65a0/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
index 9d1be1f..843be54 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
@@ -281,10 +281,18 @@ public class JDBCSequentialFile implements SequentialFile {
return readPosition;
}
+
@Override
public void close() throws Exception {
+ close(true);
+ }
+
+ @Override
+ public void close(boolean waitOnSync) throws Exception {
isOpen.set(false);
- sync();
+ if (waitOnSync) {
+ sync();
+ }
fileFactory.sequentialFileClosed(this);
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30ba65a0/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java
index 53c9890..49130e6 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/SequentialFile.java
@@ -97,6 +97,14 @@ public interface SequentialFile {
void close() throws Exception;
+ /** When closing a file from a finalize block, you cant wait on syncs or anything like that.
+ * otherwise the VM may hung. Especially on the testsuite. */
+ default void close(boolean waitSync) throws Exception {
+ // by default most implementations are just using the regular close..
+ // if the close needs sync, please use this parameter or fianlizations may get stuck
+ close();
+ }
+
void sync() throws IOException;
long size() throws Exception;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30ba65a0/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java
index 6ca5538..7863406 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java
@@ -97,41 +97,50 @@ public class AIOSequentialFile extends AbstractSequentialFile {
return new AIOSequentialFile(aioFactory, -1, -1, getFile().getParentFile(), getFile().getName(), null);
}
+
+ @Override
+ public void close() throws IOException, InterruptedException, ActiveMQException {
+ close(true);
+ }
+
+
@Override
- public synchronized void close() throws IOException, InterruptedException, ActiveMQException {
+ public synchronized void close(boolean waitSync) throws IOException, InterruptedException, ActiveMQException {
if (!opened) {
return;
}
super.close();
- final String fileName = this.getFileName();
- try {
- int waitCount = 0;
- while (!pendingCallbacks.await(10, TimeUnit.SECONDS)) {
- waitCount++;
- if (waitCount == 1) {
- final ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
- for (ThreadInfo threadInfo : threads) {
- ActiveMQJournalLogger.LOGGER.warn(threadInfo.toString());
+ if (waitSync) {
+ final String fileName = this.getFileName();
+ try {
+ int waitCount = 0;
+ while (!pendingCallbacks.await(10, TimeUnit.SECONDS)) {
+ waitCount++;
+ if (waitCount == 1) {
+ final ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
+ for (ThreadInfo threadInfo : threads) {
+ ActiveMQJournalLogger.LOGGER.warn(threadInfo.toString());
+ }
+ factory.onIOError(new IOException("Timeout on close"), "Timeout on close", this);
}
- factory.onIOError(new IOException("Timeout on close"), "Timeout on close", this);
+ ActiveMQJournalLogger.LOGGER.warn("waiting pending callbacks on " + fileName + " from " + (waitCount * 10) + " seconds!");
}
- ActiveMQJournalLogger.LOGGER.warn("waiting pending callbacks on " + fileName + " from " + (waitCount * 10) + " seconds!");
- }
- } catch (InterruptedException e) {
- ActiveMQJournalLogger.LOGGER.warn("interrupted while waiting pending callbacks on " + fileName, e);
- throw e;
- } finally {
+ } catch (InterruptedException e) {
+ ActiveMQJournalLogger.LOGGER.warn("interrupted while waiting pending callbacks on " + fileName, e);
+ throw e;
+ } finally {
- opened = false;
+ opened = false;
- timedBuffer = null;
+ timedBuffer = null;
- aioFile.close();
+ aioFile.close();
- aioFile = null;
+ aioFile = null;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30ba65a0/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java
index 0091f30..7619d1a 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedSequentialFile.java
@@ -334,6 +334,11 @@ final class MappedSequentialFile implements SequentialFile {
@Override
public void close() {
+ close(true);
+ }
+
+ @Override
+ public void close(boolean waitOnSync) {
if (this.mappedFile != null) {
this.mappedFile.close();
this.mappedFile = null;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30ba65a0/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
index caabf46..8e586ff 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
@@ -349,7 +349,7 @@ public final class Page implements Comparable<Page> {
protected void finalize() {
try {
if (file != null && file.isOpen()) {
- file.close();
+ file.close(false);
}
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.pageFinaliseError(e);