You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "clebertsuconic (via GitHub)" <gi...@apache.org> on 2023/11/15 19:41:27 UTC
[PR] ARTEMIS-4505 Cleanup page transactions on startup of the broker [activemq-artemis]
clebertsuconic opened a new pull request, #4677:
URL: https://github.com/apache/activemq-artemis/pull/4677
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ARTEMIS-4505 Cleanup page transactions on startup of the broker [activemq-artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #4677:
URL: https://github.com/apache/activemq-artemis/pull/4677#discussion_r1394823587
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java:
##########
@@ -583,22 +591,65 @@ public void forEachTransaction(BiConsumer<Long, PageTransactionInfo> transaction
public Future<Object> rebuildCounters(Set<Long> storedLargeMessages) {
Map<Long, PageTransactionInfo> transactionsSet = new LongObjectHashMap();
// making a copy
- transactions.forEach(transactionsSet::put);
+ transactions.forEach((a, b) -> {
+ transactionsSet.put(a, b);
+ b.setOrphaned(true);
+ });
+ AtomicLong minLargeMessageID = new AtomicLong(Long.MAX_VALUE);
+
+ // make a copy of the stores
+ Map<SimpleString, PagingStore> currentStoreMap = new HashMap<>();
+ stores.forEach(currentStoreMap::put);
if (logger.isDebugEnabled()) {
logger.debug("Page Transactions during rebuildCounters:");
transactionsSet.forEach((a, b) -> logger.debug("{} = {}", a, b));
}
- stores.forEach((address, pgStore) -> {
- PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages);
+ currentStoreMap.forEach((address, pgStore) -> {
+ PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages, minLargeMessageID);
logger.debug("Setting destination {} to rebuild counters", address);
managerExecutor.execute(rebuildManager);
});
+ managerExecutor.execute(() -> cleanupPageTransactions(transactionsSet, currentStoreMap));
+
FutureTask<Object> task = new FutureTask<>(() -> null);
managerExecutor.execute(task);
return task;
}
+
+ private void cleanupPageTransactions(Map<Long, PageTransactionInfo> transactionSet, Map<SimpleString, PagingStore> currentStoreMap) {
+ if (server == null) {
+ logger.warn("Server attribute was not set, cannot proceed with page transaction cleanup");
+ }
+ AtomicBoolean proceed = new AtomicBoolean(true);
+ currentStoreMap.forEach((a, b) -> {
+ if (!b.getCursorProvider().isRebuildDone()) {
+ logger.warn("cannot proceed on cleaning up page transactions as page cursor for {} is not done rebuilding it", b.getAddress());
+ proceed.set(false);
+ }
+ });
+
+ if (!proceed.get()) {
Review Comment:
Might be worth a comment explaining the thinking as I starred at it for awhile trying to figure out where it was being restarted etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ARTEMIS-4505 Cleanup page transactions on startup of the broker [activemq-artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #4677:
URL: https://github.com/apache/activemq-artemis/pull/4677#discussion_r1394786609
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java:
##########
@@ -67,11 +67,27 @@ public final class PageTransactionInfoImpl implements PageTransactionInfo {
private List<LateDelivery> lateDeliveries;
+ /** To be used during by the RebuildManager.
+ * When reading transactions not found transactions are marked as done. */
+ private boolean orphaned;
+
+
Review Comment:
Extra newline added, seems like some extras were removed down below so probably want to prune this one
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java:
##########
@@ -583,22 +591,65 @@ public void forEachTransaction(BiConsumer<Long, PageTransactionInfo> transaction
public Future<Object> rebuildCounters(Set<Long> storedLargeMessages) {
Map<Long, PageTransactionInfo> transactionsSet = new LongObjectHashMap();
// making a copy
- transactions.forEach(transactionsSet::put);
+ transactions.forEach((a, b) -> {
+ transactionsSet.put(a, b);
+ b.setOrphaned(true);
+ });
+ AtomicLong minLargeMessageID = new AtomicLong(Long.MAX_VALUE);
+
+ // make a copy of the stores
+ Map<SimpleString, PagingStore> currentStoreMap = new HashMap<>();
+ stores.forEach(currentStoreMap::put);
if (logger.isDebugEnabled()) {
logger.debug("Page Transactions during rebuildCounters:");
transactionsSet.forEach((a, b) -> logger.debug("{} = {}", a, b));
}
- stores.forEach((address, pgStore) -> {
- PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages);
+ currentStoreMap.forEach((address, pgStore) -> {
+ PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages, minLargeMessageID);
logger.debug("Setting destination {} to rebuild counters", address);
managerExecutor.execute(rebuildManager);
});
+ managerExecutor.execute(() -> cleanupPageTransactions(transactionsSet, currentStoreMap));
+
FutureTask<Object> task = new FutureTask<>(() -> null);
managerExecutor.execute(task);
return task;
}
+
+ private void cleanupPageTransactions(Map<Long, PageTransactionInfo> transactionSet, Map<SimpleString, PagingStore> currentStoreMap) {
+ if (server == null) {
+ logger.warn("Server attribute was not set, cannot proceed with page transaction cleanup");
+ }
+ AtomicBoolean proceed = new AtomicBoolean(true);
+ currentStoreMap.forEach((a, b) -> {
+ if (!b.getCursorProvider().isRebuildDone()) {
+ logger.warn("cannot proceed on cleaning up page transactions as page cursor for {} is not done rebuilding it", b.getAddress());
+ proceed.set(false);
+ }
+ });
+
+ if (!proceed.get()) {
Review Comment:
Is there some additional handling to retry or is this cleanup left for another restart? It's unclear to me what the state is after the code determines it can't proceed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ARTEMIS-4505 Cleanup page transactions on startup of the broker [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4677:
URL: https://github.com/apache/activemq-artemis/pull/4677#discussion_r1394869773
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java:
##########
@@ -583,22 +591,65 @@ public void forEachTransaction(BiConsumer<Long, PageTransactionInfo> transaction
public Future<Object> rebuildCounters(Set<Long> storedLargeMessages) {
Map<Long, PageTransactionInfo> transactionsSet = new LongObjectHashMap();
// making a copy
- transactions.forEach(transactionsSet::put);
+ transactions.forEach((a, b) -> {
+ transactionsSet.put(a, b);
+ b.setOrphaned(true);
+ });
+ AtomicLong minLargeMessageID = new AtomicLong(Long.MAX_VALUE);
+
+ // make a copy of the stores
+ Map<SimpleString, PagingStore> currentStoreMap = new HashMap<>();
+ stores.forEach(currentStoreMap::put);
if (logger.isDebugEnabled()) {
logger.debug("Page Transactions during rebuildCounters:");
transactionsSet.forEach((a, b) -> logger.debug("{} = {}", a, b));
}
- stores.forEach((address, pgStore) -> {
- PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages);
+ currentStoreMap.forEach((address, pgStore) -> {
+ PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages, minLargeMessageID);
logger.debug("Setting destination {} to rebuild counters", address);
managerExecutor.execute(rebuildManager);
});
+ managerExecutor.execute(() -> cleanupPageTransactions(transactionsSet, currentStoreMap));
+
FutureTask<Object> task = new FutureTask<>(() -> null);
managerExecutor.execute(task);
return task;
}
+
+ private void cleanupPageTransactions(Map<Long, PageTransactionInfo> transactionSet, Map<SimpleString, PagingStore> currentStoreMap) {
+ if (server == null) {
+ logger.warn("Server attribute was not set, cannot proceed with page transaction cleanup");
+ }
+ AtomicBoolean proceed = new AtomicBoolean(true);
+ currentStoreMap.forEach((a, b) -> {
+ if (!b.getCursorProvider().isRebuildDone()) {
+ logger.warn("cannot proceed on cleaning up page transactions as page cursor for {} is not done rebuilding it", b.getAddress());
+ proceed.set(false);
+ }
+ });
+
+ if (!proceed.get()) {
Review Comment:
I just did. thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ARTEMIS-4505 Cleanup page transactions on startup of the broker [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic merged PR #4677:
URL: https://github.com/apache/activemq-artemis/pull/4677
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ARTEMIS-4505 Cleanup page transactions on startup of the broker [activemq-artemis]
Posted by "clebertsuconic (via GitHub)" <gi...@apache.org>.
clebertsuconic commented on code in PR #4677:
URL: https://github.com/apache/activemq-artemis/pull/4677#discussion_r1394809522
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java:
##########
@@ -583,22 +591,65 @@ public void forEachTransaction(BiConsumer<Long, PageTransactionInfo> transaction
public Future<Object> rebuildCounters(Set<Long> storedLargeMessages) {
Map<Long, PageTransactionInfo> transactionsSet = new LongObjectHashMap();
// making a copy
- transactions.forEach(transactionsSet::put);
+ transactions.forEach((a, b) -> {
+ transactionsSet.put(a, b);
+ b.setOrphaned(true);
+ });
+ AtomicLong minLargeMessageID = new AtomicLong(Long.MAX_VALUE);
+
+ // make a copy of the stores
+ Map<SimpleString, PagingStore> currentStoreMap = new HashMap<>();
+ stores.forEach(currentStoreMap::put);
if (logger.isDebugEnabled()) {
logger.debug("Page Transactions during rebuildCounters:");
transactionsSet.forEach((a, b) -> logger.debug("{} = {}", a, b));
}
- stores.forEach((address, pgStore) -> {
- PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages);
+ currentStoreMap.forEach((address, pgStore) -> {
+ PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages, minLargeMessageID);
logger.debug("Setting destination {} to rebuild counters", address);
managerExecutor.execute(rebuildManager);
});
+ managerExecutor.execute(() -> cleanupPageTransactions(transactionsSet, currentStoreMap));
+
FutureTask<Object> task = new FutureTask<>(() -> null);
managerExecutor.execute(task);
return task;
}
+
+ private void cleanupPageTransactions(Map<Long, PageTransactionInfo> transactionSet, Map<SimpleString, PagingStore> currentStoreMap) {
+ if (server == null) {
+ logger.warn("Server attribute was not set, cannot proceed with page transaction cleanup");
+ }
+ AtomicBoolean proceed = new AtomicBoolean(true);
+ currentStoreMap.forEach((a, b) -> {
+ if (!b.getCursorProvider().isRebuildDone()) {
+ logger.warn("cannot proceed on cleaning up page transactions as page cursor for {} is not done rebuilding it", b.getAddress());
+ proceed.set(false);
+ }
+ });
+
+ if (!proceed.get()) {
Review Comment:
In case one of the PageStore cleanup failed for any reason, I would prefer to never do this cleanup, and only try it at a next restart.
It shouldn't really happen, but I wanted to add this check here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ARTEMIS-4505 Cleanup page transactions on startup of the broker [activemq-artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #4677:
URL: https://github.com/apache/activemq-artemis/pull/4677#discussion_r1394823587
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java:
##########
@@ -583,22 +591,65 @@ public void forEachTransaction(BiConsumer<Long, PageTransactionInfo> transaction
public Future<Object> rebuildCounters(Set<Long> storedLargeMessages) {
Map<Long, PageTransactionInfo> transactionsSet = new LongObjectHashMap();
// making a copy
- transactions.forEach(transactionsSet::put);
+ transactions.forEach((a, b) -> {
+ transactionsSet.put(a, b);
+ b.setOrphaned(true);
+ });
+ AtomicLong minLargeMessageID = new AtomicLong(Long.MAX_VALUE);
+
+ // make a copy of the stores
+ Map<SimpleString, PagingStore> currentStoreMap = new HashMap<>();
+ stores.forEach(currentStoreMap::put);
if (logger.isDebugEnabled()) {
logger.debug("Page Transactions during rebuildCounters:");
transactionsSet.forEach((a, b) -> logger.debug("{} = {}", a, b));
}
- stores.forEach((address, pgStore) -> {
- PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages);
+ currentStoreMap.forEach((address, pgStore) -> {
+ PageCounterRebuildManager rebuildManager = new PageCounterRebuildManager(this, pgStore, transactionsSet, storedLargeMessages, minLargeMessageID);
logger.debug("Setting destination {} to rebuild counters", address);
managerExecutor.execute(rebuildManager);
});
+ managerExecutor.execute(() -> cleanupPageTransactions(transactionsSet, currentStoreMap));
+
FutureTask<Object> task = new FutureTask<>(() -> null);
managerExecutor.execute(task);
return task;
}
+
+ private void cleanupPageTransactions(Map<Long, PageTransactionInfo> transactionSet, Map<SimpleString, PagingStore> currentStoreMap) {
+ if (server == null) {
+ logger.warn("Server attribute was not set, cannot proceed with page transaction cleanup");
+ }
+ AtomicBoolean proceed = new AtomicBoolean(true);
+ currentStoreMap.forEach((a, b) -> {
+ if (!b.getCursorProvider().isRebuildDone()) {
+ logger.warn("cannot proceed on cleaning up page transactions as page cursor for {} is not done rebuilding it", b.getAddress());
+ proceed.set(false);
+ }
+ });
+
+ if (!proceed.get()) {
Review Comment:
Might be worth a comment explaining the thinking as I stared at it for awhile trying to figure out where it was being restarted etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org