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
Fail-fast if max-idle-seconds is set below 2 seconds #14727
Fail-fast if max-idle-seconds is set below 2 seconds #14727
Conversation
There was a incorrect check here that waited for eviction by MaxIdle parameter and touched the record in the same time
…14697-max-idle-seconds
…fix/3.13/14697-max-idle-seconds
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.
minor comment about doc. Otherwise looks good to me 👍
@@ -202,6 +204,9 @@ | |||
protected static final String NULL_AGGREGATOR_IS_NOT_ALLOWED = "Aggregator should not be null!"; | |||
protected static final String NULL_PROJECTION_IS_NOT_ALLOWED = "Projection should not be null!"; | |||
|
|||
protected static final String MAX_IDLE_TIME_IS_TOO_SMALL = "Parameter maxIdle in seconds representation must be greater or" |
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 am not arguing my english is perfect here but I think the message must be "greater than or equal to"
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.
You're right. Fixed. Thanks.
@@ -139,6 +139,8 @@ | |||
protected static final String NULL_LISTENER_IS_NOT_ALLOWED = "Null listener is not allowed!"; | |||
protected static final String NULL_AGGREGATOR_IS_NOT_ALLOWED = "Aggregator should not be null!"; | |||
protected static final String NULL_PROJECTION_IS_NOT_ALLOWED = "Projection should not be null!"; | |||
protected static final String MAX_IDLE_TIME_IS_TOO_SMALL = "Parameter maxIdle in seconds representation must be greater or " |
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.
the same issue with "greater than or equal to"
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.
Fixed
…fix/3.13/14697-max-idle-seconds
…fix/3.13/14697-max-idle-seconds
One concern - what if the user is already using IMap with expiration and is setting the TTL to 1 second? We will start throwing |
@mmedenjak @Test
public void testOneSecondTtl() {
final IMap<String, String> map = getInstance().getMap(randomString());
long start, end;
start = System.currentTimeMillis();
for (int i = 0; i < 300000; i++) {
map.put("key", "value", 2000, MILLISECONDS);
end = System.currentTimeMillis();
assertEquals("Iteration " + i + ". Ms until now: " + (end - start), "value", map.get("key"));
}
} It takes about 20 seconds on my machine and test passes fine. When I change TTL value to 1999 milliseconds, the test fails within the first second. I guess having a 1 second TTL does not make sense either. Because we round down creation time. If the entry is created at x4998ms time offset, we record it as x4000 by rounding down. When we check elapsedMillis during map.get, most of the time elapsed time is larger than 1000ms. |
@mmedenjak |
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.
Ok, ok, I'm convinced :) Maybe we can add this as a note in the changelog cc @Serdaro
4 concerns with this change:
|
@ahmetmircik It's a tricky question. I guess this was introduced because we shaved off some data to make HD records more compact, which is great. Now, we have this quirky behaviour.
|
Without increasing precision it won't help much, e.g., I agree that we should remove a throwing of the exception and add to javadoc that our current precision is 1s and all below 1s can lead to unexpected behaviour. |
Fixes: #14697