- Notifications
You must be signed in to change notification settings - Fork 25.5k
Add cache support in TransportGetAllocationStatsAction
#124898
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
Conversation
Hi @JeremyDahlgren, I've created a changelog YAML for you. |
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
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.
Great stuff. I've left some suggestions.
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Outdated Show resolved Hide resolved
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Outdated Show resolved Hide resolved
...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
6403432
to 53f307c
Compare ...ava/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java Outdated Show resolved Hide resolved
84ec448
to 9b87c4b
Compare Hi @JeremyDahlgren, I've created a changelog YAML for you. |
2c040be
to 94be786
Compare public static final Setting<TimeValue> CACHE_TTL_SETTING = Setting.timeSetting( | ||
"cluster.routing.allocation.stats.cache.ttl", |
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.
What visibility/exposure should this setting have? I saw other cluster.routing.allocation.*
settings in docs
in cluster-level-shard-allocation-routing-settings.md
. Should it be documented there?
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.
Yes, we need to add documentation, either in this PR or in follow up. Both are fine.
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.
++ would prefer to add the docs in the same PR, otherwise it tends to get forgotten
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
Hi @JeremyDahlgren, I've created a changelog YAML for you. |
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.
LGTM. Docs update can be a follow up
public static final Setting<TimeValue> CACHE_TTL_SETTING = Setting.timeSetting( | ||
"cluster.routing.allocation.stats.cache.ttl", |
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.
Yes, we need to add documentation, either in this PR or in follow up. Both are fine.
Map<String, NodeAllocationStats> get() { | ||
| ||
if (ttlMillis == 0L) { | ||
return null; | ||
} | ||
| ||
final var stats = cachedStats.get(); | ||
| ||
if (stats == null || threadPool.relativeTimeInMillis() - stats.timestampMillis > ttlMillis) { | ||
return null; | ||
} | ||
| ||
return stats.stats; | ||
} |
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.
nit: maybe remove empty lines
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Show resolved Hide resolved
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.
Tiny comments only, otherwise LGTM2
public static final Setting<TimeValue> CACHE_TTL_SETTING = Setting.timeSetting( | ||
"cluster.routing.allocation.stats.cache.ttl", |
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.
++ would prefer to add the docs in the same PR, otherwise it tends to get forgotten
final var stats = cachedStats.get(); | ||
| ||
if (stats == null || threadPool.relativeTimeInMillis() - stats.timestampMillis > ttlMillis) { | ||
return null; |
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.
Should we clear cachedStats
here if it's expired? I guess we're just about to overwrite it with a fresh copy so doesn't really matter? If so, could we have a comment just noting this decision for the next person?
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Outdated Show resolved Hide resolved
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Outdated Show resolved Hide resolved
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Outdated Show resolved Hide resolved
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Outdated Show resolved Hide resolved
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Outdated Show resolved Hide resolved
...rg/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsActionTests.java Outdated Show resolved Hide resolved
Adds a new setting TransportGetAllocationStatsAction.CACHE_MAX_AGE_SETTING to configure the max age for cached AllocationStats on the master. The default value is currently 1 minute per the suggestion in issue 110716. Closes elastic#110716
d41aa7f
to 2e6e6ad
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.
Documentation update LGTM too
Hi @JeremyDahlgren, I've created a changelog YAML for you. |
💔 Backport failedThe backport operation could not be completed due to the following error:
You can use sqren/backport to manually backport by running |
Adds a new cache and setting TransportGetAllocationStatsAction.CACHE_TTL_SETTING "cluster.routing.allocation.stats.cache.ttl" to configure the max age for cached NodeAllocationStats on the master. The default value is currently 1 minute per the suggestion in issue 110716. Closes elastic#110716
Adds a new cache and setting TransportGetAllocationStatsAction.CACHE_TTL_SETTING "cluster.routing.allocation.stats.cache.ttl" to configure the max age for cached NodeAllocationStats on the master. The default value is currently 1 minute per the suggestion in issue 110716. Closes elastic#110716
Adds a new cache and setting TransportGetAllocationStatsAction.CACHE_TTL_SETTING "cluster.routing.allocation.stats.cache.ttl" to configure the max age for cached NodeAllocationStats on the master. The default value is currently 1 minute per the suggestion in issue 110716. Closes elastic#110716
Adds a new dynamic setting
TransportGetAllocationStatsAction.CACHE_TTL_SETTING
"cluster.routing.allocation.stats.cache.ttl"
to configure the time to live for cachedNodeAllocationStats
on the master. The default value is currently 1 minute per the suggestion in issue #110716.Closes #110716