Skip to content
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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jbertram
Copy link
Contributor

@jbertram jbertram commented Nov 1, 2024

No description provided.

pom.xml Outdated Show resolved Hide resolved
@gemmellr
Copy link
Member

gemmellr commented Nov 1, 2024

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

@jbertram
Copy link
Contributor Author

jbertram commented Nov 1, 2024

@gemmellr, I took care of the documentation.

@jbertram jbertram force-pushed the ARTEMIS-5142 branch 2 times, most recently from cb291cc to 1dd02bb Compare November 11, 2024 20:51
@gemmellr
Copy link
Member

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.

@clebertsuconic
Copy link
Contributor

this LGTM as long as tests are working fine

@gemmellr
Copy link
Member

Other than those bits I commented on where its clearly not ok? :)

@clebertsuconic
Copy link
Contributor

@gemmellr I said.. loTm... not clearly to you :)

@jbertram
Copy link
Contributor Author

@gemmellr, the extra/modified tests in your commit look good. How do you want to merge them? Do you want to rebase on the push -f I'm about to do or do you want me to just incorporate them into my own?

@gemmellr
Copy link
Member

Feel free to squash them

@jbertram
Copy link
Contributor Author

I decided to keep your commit. Merge when ready.

Copy link
Member

@gemmellr gemmellr left a 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.

Comment on lines +1381 to +1384
} 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));
Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Comment on lines +70 to +71
** 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.
Copy link
Member

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

@gemmellr
Copy link
Member

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?

@jbertram
Copy link
Contributor Author

...setting expiry-delay to 0 really makes no sense to begin with...

That surely means someone will do it. I'll add a test and update the logic to deal with this.

@jbertram jbertram marked this pull request as draft December 10, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants