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


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -228,11 +228,58 @@ private void configureSizeMetric() {
       size.setMax(maxSize, maxSize, maxMessages, maxMessages);
    }
 
+   private boolean validateNewSettings(final AddressSettings addressSettings) {
+
+      Long newPageLimitBytes = addressSettings.getPageLimitBytes();
+
+      if (newPageLimitBytes != null && newPageLimitBytes < 0) {
+         newPageLimitBytes = null;
+      }
+
+      int newPageSize = 
storageManager.getAllowedPageSize(addressSettings.getPageSizeBytes());
+
+      if (newPageLimitBytes != null && newPageSize > 0) {
+
+         if (newPageSize > newPageLimitBytes) {
+            ActiveMQServerLogger.LOGGER.pageSettingsFailedApply(storeName, 
addressSettings, "pageLimitBytes is smaller than pageSize. It should allow at 
least one page file");
+            return false;
+         }
+
+         long newEstimatedMaxPages = newPageLimitBytes / newPageSize;
+
+         long existingNumberOfPages;
+         if (!running) {
+            try {
+               checkFileFactory();
+               List<String> files = this.fileFactory.listFiles("page");
+               existingNumberOfPages = files.size();
+            } catch (Exception e) {
+               ActiveMQServerLogger.LOGGER.pageSettingsFailedApply(storeName, 
addressSettings, "failed to get existing page files with exception: " + e);
+               return false;
+            }
+         } else {
+            existingNumberOfPages = this.numberOfPages;
+         }
+
+         if (existingNumberOfPages > newEstimatedMaxPages) {
+            ActiveMQServerLogger.LOGGER.pageSettingsFailedApply(storeName, 
addressSettings, "estimated max pages " + newEstimatedMaxPages + " 
(pageLimitBytes / pageSize) is less than current number of pages " + 
existingNumberOfPages);
+            return false;
+         }

Review Comment:
   The diff makes it seem like you are adding that 'you cant set a limit lower 
than what is in use' behaviour here in this commit? You are saying that the 
existing code already does that, where is that happening? Also feels awkward to 
have it happening in 2 places without apparent relation.
   
   I was actually more interested in the appearance of a 'shut broker down, 
decrease limit, start up...fail new validation, get no settings applied at all' 
issue that I commented on around the test, but runtime behaviour is also a key 
issue.



-- 
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