-
Notifications
You must be signed in to change notification settings - Fork 924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARTEMIS-5142 setting 0 for min/max expiry-delivery not working as expected #5334
base: main
Are you sure you want to change the base?
Conversation
...jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
Outdated
Show resolved
Hide resolved
299337e
to
af99bb4
Compare
The min and max settings aren't listed in the address-settings doc, might be good to add them with this. (They are covered in the expiry section referenced from the address setting doc for the other expiry setting). |
af99bb4
to
81ad29f
Compare
@gemmellr, I took care of the documentation. |
81ad29f
to
a02194b
Compare
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/ExpiryTest.java
Outdated
Show resolved
Hide resolved
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/ExpiryTest.java
Outdated
Show resolved
Hide resolved
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/ExpiryTest.java
Outdated
Show resolved
Hide resolved
cb291cc
to
1dd02bb
Compare
...is-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
Outdated
Show resolved
Hide resolved
...is-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
Outdated
Show resolved
Hide resolved
In addition to the above comments on potential for mismatch between doc and/or expectations and the actual behaviour...I pushed another commit with some more tests, and tweaks to some of the existing tests, to more strictly verify the resulting expiration value set is in the expected range. See what you think. |
this LGTM as long as tests are working fine |
Other than those bits I commented on where its clearly not ok? :) |
@gemmellr I said.. loTm... not clearly to you :) |
@gemmellr, the extra/modified tests in your commit look good. How do you want to merge them? Do you want to rebase on the |
Feel free to squash them |
297cd45
to
55c71f6
Compare
I decided to keep your commit. Merge when ready. |
55c71f6
to
85a960d
Compare
...erver/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImplTest.java
Outdated
Show resolved
Hide resolved
85a960d
to
0d48239
Compare
0d48239
to
0571edb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to merge this earlier when I took another look at the overall method and changes, and noticed what I would consider a bug, and a couple other potential bugs or things to [re]consider.
I instead rebased the existing changes and added another commit (temporary, just to make it easy to see the new changes) fixing the main issue I noticed around min-expiry-delay = 0, where it wouldnt do anything for a messsage with expiration actually set to the future, with it instead only updating expirations already from the past (like the existing test was using by setting it to 1). That seemed wrong, as configuring a minimum of '0 means dont expire' should remove any expiration, regardless whether it started as past/present/future, if a minimum of 0 is being treated as a special case for no expiration to occur.
} else if (maxExpiration != AddressSettings.DEFAULT_MAX_EXPIRY_DELAY && message.getExpiration() >= (System.currentTimeMillis() + maxExpiration)) { | ||
message.setExpiration(getExpirationToSet(maxExpiration)); | ||
} else if (minExpiration != AddressSettings.DEFAULT_MIN_EXPIRY_DELAY && (minExpiration == 0 || message.getExpiration() < (System.currentTimeMillis() + minExpiration))) { | ||
message.setExpiration(getExpirationToSet(minExpiration)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didnt change the max-expiry-delay=0 handling, as I'm now debating what it should do overall. It has a similar but reversed behaviour, that it wont do anything for an expiration in the past, but will for present/future expirations. Which on one hand seems perfectly fair; originally already expired, definitely 'shorter expiration' than a maximum of never-expire. However on the other hand its also totally at odds with it resetting a future-expiration to instead never-expire.
The special handling for max-expiry-delay=0 meaning dont-expire, mainly seems to be there / necessary because of the earlier application when a message has no expiration set meaning it then gets max-expiry-delay applied if configured (which previously then immediately expired before these changes, and now would remain with no-expiry).
In the later cases here of a message which does have an expiration already, it seems a foggier that it should remove it for max-expiry-delay. For such messages, max-expiry-delay is documented to only affect existing expirations greater than the maximum, reducing them to the maximum. A max-expiry-delay of 0 meaning no-expiration, is then arguably still a 'larger value' (never/infinite) than any specific expiration point that might be set, arguably meaning it shouldnt be changed due to the max-expiry-delay. Then, if you do want to stop such a message expiring which already have an expiration set, the way is instead setting a min-expiry-delay=0 to handle that case. If on the other hand a setting of 0 just always means 'set no-expiration' even for the max-expiry-delay like it does in most cases now, then should it not also do that even for the messages that originally had expiration in the past? (by adding a similar maxExpiration=0 escape to the check as I did for minExpiration)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm...So maybe the current behavior of min-expiry-delay
and max-expiry-delay
is actually correct in a strict semantic interpretation and instead of making 0
behave in a special way we should just add a new address-setting to strip the expiration from incoming messages so they never expire categorically which is the semantic that the Jira is really aimed at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put together #5390 which does this very thing. Let me know what you think.
** If `max-expiry-delay` is not defined then the message will be set to `min-expiry-delay`. | ||
** If `min-expiry-delay` is not defined then the message will not be changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever we end up doing, the specific 0=special handling that applies should probably be documented, its not mentioned anywhere currently
Also, I noticed the regular expiry-delay (not min/max) setting has the same '0 makes it set expire now' behaviour because it will set the current time as the expiration. It is subtly different from the min/max case in that the setting only ever applies to messages with an existing expiration, so setting expiry-delay to 0 really makes no sense to begin with, so it could more reasonably just be left as it is, but I wonder if it should also special-case it like min/max now do? |
That surely means someone will do it. I'll add a test and update the logic to deal with this. |
No description provided.