gemmellr commented on code in PR #5128:
URL: https://github.com/apache/activemq-artemis/pull/5128#discussion_r1705762102


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -228,11 +228,34 @@ private void configureSizeMetric() {
       size.setMax(maxSize, maxSize, maxMessages, maxMessages);
    }
 
+   private boolean validateNewSettings(final AddressSettings addressSettings) {
+
+      Long newPageLimitBytes = addressSettings.getPageLimitBytes();
+
+      if (newPageLimitBytes != null && newPageLimitBytes.longValue() < 0) {
+         newPageLimitBytes = null;
+      }
+      int newPageSize = 
storageManager.getAllowedPageSize(addressSettings.getPageSizeBytes());
+      if (newPageLimitBytes != null && newPageSize > 0) {
+         long newEstimatedMaxPages = newPageLimitBytes / newPageSize;
+         if (this.numberOfPages > newEstimatedMaxPages) {
+            ActiveMQServerLogger.LOGGER.pageSettingsFailedApply(storeName, 
addressSettings, "estimated max pages " + newEstimatedMaxPages + " is less than 
current number of pages " + this.numberOfPages);
+            return false;
+         }
+      }
+      return true;
+   }
+
    /**
     * @param addressSettings
     */
    @Override
    public void applySetting(final AddressSettings addressSettings) {
+
+      if (!validateNewSettings(addressSettings)) {
+         return;
+      }

Review Comment:
   The limit > page size requirement would remove any issue with e.g 0 page 
files at the low end. Though essentially the same thing occurs with `n` files 
at the top end, unless the limit is always a multiple of the page size.
   
   The main issue here is that the limit is tracked by a file count based on 
current limit/size, and so any existing 'old' files of the 'wrong' size can 
over/underutilise the effective limit if you adjust the page size with 
outstanding page files. There doesnt seem to be a way around that without 
byte-level tracking, which is likely to be awkward.
   
   I think we should perhaps just better document that the effective limit is a 
file count based on current limit/page size, and so changing page size whilst 
there are existing outstanding pages can lead to such behaviour and if you want 
to influence things to e.g unblock earlier it might be necessary to adjust the 
limit at the same time whilst those old files are present.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to