From 9b104930c25beeba646d92ab38c6038a11f1e227 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Tue, 13 Feb 2018 11:38:16 -0500 Subject: [PATCH] ARTEMIS-1663 Fixing Encoding on PageCountPendingImpl The PageCountPendingImpl was increasing the encode size without using its full allocation. This was causing issues on replication as the encode is also used to determine the size of the packets. however the packets were not receive the full allocated data causing missing packets on the replication and test failures. This is fixing the issue --- .../core/paging/cursor/impl/PageSubscriptionCounterImpl.java | 4 ++-- .../activemq/artemis/core/persistence/StorageManager.java | 2 +- .../impl/journal/AbstractJournalStorageManager.java | 4 ++-- .../persistence/impl/journal/codec/PageCountPendingImpl.java | 4 ++-- .../core/persistence/impl/nullpm/NullStorageManager.java | 2 +- .../artemis/core/transaction/impl/TransactionImplTest.java | 2 +- .../artemis/tests/integration/client/SendAckFailTest.java | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java index 3bb56f833b..f7a82e1b27 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java @@ -135,7 +135,7 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { // We have to make sure this is sync here // not syncing this to disk may cause the page files to be out of sync on pages. // we can't afford the case where a page file is written without a record here - long id = storage.storePendingCounter(this.subscriptionID, page.getPageId(), increment); + long id = storage.storePendingCounter(this.subscriptionID, page.getPageId()); pendingInfo = new PendingCounter(id, increment, size); pendingCounters.put((long) page.getPageId(), pendingInfo); } else { @@ -422,7 +422,7 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { /** * @param id * @param count - * @param size + * @param persistentSize */ PendingCounter(long id, int count, long persistentSize) { super(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java index f9793d89c3..d025d5e991 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java @@ -338,7 +338,7 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent { */ long storePageCounter(long txID, long queueID, long value, long persistentSize) throws Exception; - long storePendingCounter(long queueID, long pageID, int inc) throws Exception; + long storePendingCounter(long queueID, long pageID) throws Exception; void deleteIncrementRecord(long txID, long recordID) throws Exception; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java index ada5b90711..970c926277 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java @@ -1388,11 +1388,11 @@ public abstract class AbstractJournalStorageManager extends CriticalComponentImp } @Override - public long storePendingCounter(final long queueID, final long pageID, final int inc) throws Exception { + public long storePendingCounter(final long queueID, final long pageID) throws Exception { readLock(); try { final long recordID = idGenerator.generateID(); - PageCountPendingImpl pendingInc = new PageCountPendingImpl(queueID, pageID, inc); + PageCountPendingImpl pendingInc = new PageCountPendingImpl(queueID, pageID); // We must guarantee the record sync before we actually write on the page otherwise we may get out of sync // on the counter messageJournal.appendAddRecord(recordID, JournalRecordIds.PAGE_CURSOR_PENDING_COUNTER, pendingInc, true); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PageCountPendingImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PageCountPendingImpl.java index e600d466a2..b5698d1a98 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PageCountPendingImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PageCountPendingImpl.java @@ -33,7 +33,7 @@ public class PageCountPendingImpl implements EncodingSupport, PageCountPending { } - public PageCountPendingImpl(long queueID, long pageID, int inc) { + public PageCountPendingImpl(long queueID, long pageID) { this.queueID = queueID; this.pageID = pageID; } @@ -65,7 +65,7 @@ public class PageCountPendingImpl implements EncodingSupport, PageCountPending { @Override public int getEncodeSize() { - return DataConstants.SIZE_LONG * 3; + return DataConstants.SIZE_LONG * 2; } @Override diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java index 8c5e11c160..995e57b007 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java @@ -472,7 +472,7 @@ public class NullStorageManager implements StorageManager { } @Override - public long storePendingCounter(long queueID, long pageID, int inc) throws Exception { + public long storePendingCounter(long queueID, long pageID) throws Exception { return -1; } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java index 3a9a7856d7..b51be9a138 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java @@ -592,7 +592,7 @@ public class TransactionImplTest extends ActiveMQTestBase { } @Override - public long storePendingCounter(long queueID, long pageID, int inc) throws Exception { + public long storePendingCounter(long queueID, long pageID) throws Exception { return 0; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java index fe9ba17f39..68c3ea4e3c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java @@ -673,8 +673,8 @@ public class SendAckFailTest extends ActiveMQTestBase { } @Override - public long storePendingCounter(long queueID, long pageID, int inc) throws Exception { - return manager.storePendingCounter(queueID, pageID, inc); + public long storePendingCounter(long queueID, long pageID) throws Exception { + return manager.storePendingCounter(queueID, pageID); } @Override