Jelmer Marinus created ARTEMIS-4187:
---------------------------------------

             Summary: SizeAwareMetric attribute inconsistency
                 Key: ARTEMIS-4187
                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4187
             Project: ActiveMQ Artemis
          Issue Type: Bug
    Affects Versions: 2.28.0, 2.27.1, 2.27.0, 2.26.0
            Reporter: Jelmer Marinus


The SizeAwareMetric can be in an inconsistent state due to conflicting 
attribute values. 

[maxSize vs.sizeEnabled]

sizeEnabled is defined as `maxSize >= 0`. This i.e. means that when maxSize is 
set to -1 sizeEnabled is going to be set to false to indicate that no size 
checking is required. However because of the two seperate attributes they are 
inconsistent for a short period of time. This is most prevelant in the follow 
code from the SizeAwareMetric itself:
{code:java}
public void setMax(long maxSize, long lowerMarkSize, long maxElements, long 
lowerMarkElements) {
   this.maxSize = maxSize;
   this.lowerMarkSize = lowerMarkSize;
   this.maxElements = maxElements;
   this.lowerMarkElements = lowerMarkElements;
   long currentSize = sizeUpdater.get(this);
   long currentElements = elementsUpdater.get(this);
   checkOver(currentElements, currentSize);
   checkUnder(currentElements, currentSize);
} {code}
This code sets the maxSize but leaves sizeEnabled as it is. As a consequence 
the checkOver and checkUnder can be executed with maxSize and sizeEnabled in an 
inconsistent state, i.e. -1 and true. This can in turn lead to unexpected 
over/under conditions and unexpected paging behaviour.

The same is true for maxElement vs. elementsEnabled.

[maxSize vs. lowerMarkSize]

MaxSize is checked >= to the current size and lowerMarkSize is check <= current 
size. When maxSize = lowerMarkSize = current size it is a bit "unclear" if 
there is and under or over situation. 

The same is true for maxElements vs. lowerMarkElements I believe.

This is a minor/cosmetic issue.

 

I will issue a PR for both.

 

 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to