temporalio / temporalio/temporal
Negative value in the Prometheus metric cache_pinned_usage
@yycptt is already working on this.
Since Apr 16, 2026.
- Dominant language
- Go
- Stars
- 23.2k
- Forks
- 1.9k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 228
Description
Expected Behavior
The cache_pinned_usage prometheus metric reflects the actual size of pinned entries in the history cache.
Actual Behavior
The cache_pinned_usage metric can take a negative value then history.cacheSizeBasedLimit is set to true:
cache_pinned_usage{cache_type="mutablestate",service_name="history",type="history"} -4.7310617e+07
Probable cause
It is possible that the issue is related to the fact that the metric value is increased by the size of the entry only at the moment it is created:
After that, the same entry may be modified in a way that its size becomes larger.
And when the entry is released, its current size will be subtracted from the cache’s pinnedSize and reflected in the metric.
It is possible that situations where the entry size at the time of its release is larger than at the time of its creation are exactly what leads to the metric having a negative value.
Steps to Reproduce the Problem
- Enable option
history.cacheSizeBasedLimit - After some time, get the value of the
cache_pinned_usagemetric
Specifications
- Version: v1.29.1
- Platform: Linux/amd64 (RKE2 Kubernetes)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.