ARTEMIS-474 fixing page.close() deadlock with replica

This commit is contained in:
Clebert Suconic 2016-04-07 15:53:52 -04:00
parent 86a81d315d
commit 2e894554ca
4 changed files with 17 additions and 11 deletions

View File

@ -174,7 +174,7 @@ public class PageCursorProviderImpl implements PageCursorProvider {
finally { finally {
try { try {
if (page != null) { if (page != null) {
page.close(); page.close(false);
} }
} }
catch (Throwable ignored) { catch (Throwable ignored) {
@ -448,14 +448,14 @@ public class PageCursorProviderImpl implements PageCursorProvider {
} }
finally { finally {
try { try {
depagedPage.close(); depagedPage.close(false);
} }
catch (Exception e) { catch (Exception e) {
} }
storageManager.afterPageRead(); storageManager.afterPageRead();
} }
depagedPage.close(); depagedPage.close(false);
pgdMessages = pgdMessagesList.toArray(new PagedMessage[pgdMessagesList.size()]); pgdMessages = pgdMessagesList.toArray(new PagedMessage[pgdMessagesList.size()]);
} }
else { else {

View File

@ -216,8 +216,14 @@ public final class Page implements Comparable<Page> {
file.position(0); file.position(0);
} }
public synchronized void close() throws Exception { public void close() throws Exception {
if (storageManager != null) { close(false);
}
/** sendEvent means it's a close happening from a major event such moveNext.
* While reading the cache we don't need (and shouldn't inform the backup */
public synchronized void close(boolean sendEvent) throws Exception {
if (sendEvent && storageManager != null) {
storageManager.pageClosed(storeName, pageId); storageManager.pageClosed(storeName, pageId);
} }
if (pageCache != null) { if (pageCache != null) {

View File

@ -348,7 +348,7 @@ public class PagingStoreImpl implements PagingStore {
flushExecutors(); flushExecutors();
if (currentPage != null) { if (currentPage != null) {
currentPage.close(); currentPage.close(false);
currentPage = null; currentPage = null;
} }
} }
@ -390,7 +390,7 @@ public class PagingStoreImpl implements PagingStore {
currentPageId = 0; currentPageId = 0;
if (currentPage != null) { if (currentPage != null) {
currentPage.close(); currentPage.close(false);
} }
currentPage = null; currentPage = null;
@ -589,7 +589,7 @@ public class PagingStoreImpl implements PagingStore {
} }
returnPage = currentPage; returnPage = currentPage;
returnPage.close(); returnPage.close(false);
currentPage = null; currentPage = null;
// The current page is empty... which means we reached the end of the pages // The current page is empty... which means we reached the end of the pages
@ -1021,7 +1021,7 @@ public class PagingStoreImpl implements PagingStore {
int tmpCurrentPageId = currentPageId + 1; int tmpCurrentPageId = currentPageId + 1;
if (currentPage != null) { if (currentPage != null) {
currentPage.close(); currentPage.close(true);
} }
currentPage = createPage(tmpCurrentPageId); currentPage = createPage(tmpCurrentPageId);

View File

@ -306,7 +306,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon
for (Page page : map.values()) { for (Page page : map.values()) {
try { try {
page.sync(); page.sync();
page.close(); page.close(false);
} }
catch (Exception e) { catch (Exception e) {
ActiveMQServerLogger.LOGGER.errorClosingPageOnReplication(e); ActiveMQServerLogger.LOGGER.errorClosingPageOnReplication(e);
@ -698,7 +698,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon
} }
} }
else { else {
page.close(); page.close(false);
} }
} }