Skip to content

fix: correct native histogram bucket merge on scale-down#2273

Closed
arnabnandy7 wants to merge 2 commits into
prometheus:mainfrom
arnabnandy7:fix/native-histogram-bucket-resize-index
Closed

fix: correct native histogram bucket merge on scale-down#2273
arnabnandy7 wants to merge 2 commits into
prometheus:mainfrom
arnabnandy7:fix/native-histogram-bucket-resize-index

Conversation

@arnabnandy7

@arnabnandy7 arnabnandy7 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix native histogram bucket remapping when the bucket width is doubled during schema scale-down.

The previous merge formula used:

(keys[i] + 1) / 2

That works for positive bucket indexes, but not for negative even indexes. Java integer division truncates toward zero, so negative even buckets were merged into the bucket immediately to the right of the correct target.

This matches the behaviour described and aligns the merge formula with client_golang:

(keys[i] > 0 ? keys[i] + 1 : keys[i]) / 2

Why

When doubleBucketWidth() runs, counts from some negative native histogram buckets could be shifted into neighbouring buckets. That can make Prometheus interpret the reshuffled bucket counters as resets, causing spikes in queries such as:

histogram_count(rate(my_native_histogram[1m]))

Tests

Added a focused regression test for negative, zero, and positive bucket index remapping during doubleBucketWidth(Map).

Verified locally:

./mvnw test -pl prometheus-metrics-core -am \
  -Dtest=HistogramTest#testDoubleBucketWidthMergesNegativeIndexesCorrectly \
  -Dcoverage.skip=true \
  -Dcheckstyle.skip=true \
  -Dsurefire.failIfNoSpecifiedTests=false

Also verified:

./mvnw install -DskipTests -Dcoverage.skip=true

renovate Bot and others added 2 commits July 3, 2026 18:21
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [mise](https://redirect.github.com/jdx/mise) | minor | `v2026.6.14` →
`v2026.7.0` |

---

### Release Notes

<details>
<summary>jdx/mise (mise)</summary>

###
[`v2026.7.0`](https://redirect.github.com/jdx/mise/releases/tag/v2026.7.0):
: Shell expansion by default, monorepo lockfiles, and task usage mounts

[Compare
Source](https://redirect.github.com/jdx/mise/compare/vfox-v2026.6.14...vfox-v2026.7.0)

##### Added

- **env:** enable shell expansion by default; opt out with
`env_shell_expand = false`
([#&#8203;10702](https://redirect.github.com/jdx/mise/pull/10702) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **monorepo:** `mise install --monorepo` and `mise ls --monorepo`
install/list the union of tools across `[monorepo].config_roots`; new
tri-state `[monorepo].lockfile` for unified root lockfiles
([#&#8203;10707](https://redirect.github.com/jdx/mise/pull/10707) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **task:** root-level `#USAGE mount ...` in file tasks (including
shorthand `mount "cmd"`) hoists mounted usage specs onto the generated
task command
([#&#8203;10704](https://redirect.github.com/jdx/mise/pull/10704) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **github:** per-tool `github_attestations` option to disable GitHub
Artifact Attestation verification for a single tool
([#&#8203;10694](https://redirect.github.com/jdx/mise/pull/10694) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **upgrade:** `minimum_release_age` warnings now include the release
date, when the version becomes eligible, and the effective cutoff value
([#&#8203;10705](https://redirect.github.com/jdx/mise/pull/10705) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **bootstrap:** brew formulae prune is now prefix-inventory based and
can remove any linked formula outside the resolved
`[bootstrap.packages]` closure
([#&#8203;10618](https://redirect.github.com/jdx/mise/pull/10618) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **brew:** support cask `font` artifacts and additional non-install
artifact types (completions/manpages)
([#&#8203;10671](https://redirect.github.com/jdx/mise/pull/10671) by
[@&#8203;roele](https://redirect.github.com/roele)).
- **platform:** Android asset detection for tools like Termux packages
([#&#8203;10653](https://redirect.github.com/jdx/mise/pull/10653) by
[@&#8203;bltavares](https://redirect.github.com/bltavares)).

##### Fixed

- **install:** respect the lockfile-recorded backend during `--locked`
installs
([#&#8203;10599](https://redirect.github.com/jdx/mise/pull/10599) by
[@&#8203;risu729](https://redirect.github.com/risu729)).
- **install:** installer prints a clearer message and suggests `cargo
install --locked mise` on unsupported architectures
([#&#8203;10627](https://redirect.github.com/jdx/mise/pull/10627) by
[@&#8203;risu729](https://redirect.github.com/risu729)).
- **install-into:** refuse to overwrite a non-empty target directory
without `--yes`
([#&#8203;10630](https://redirect.github.com/jdx/mise/pull/10630) by
[@&#8203;JamBalaya56562](https://redirect.github.com/JamBalaya56562)).
- **aqua:** resolve bin paths with `v`-prefixed version overrides (e.g.
`sharkdp/fd@10.3.0`)
([#&#8203;10696](https://redirect.github.com/jdx/mise/pull/10696) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **aqua:** download private GitHub release assets via the API asset
endpoint when the browser URL 404s
([#&#8203;10622](https://redirect.github.com/jdx/mise/pull/10622) by
[@&#8203;yacchi](https://redirect.github.com/yacchi)).
- **brew-cask:** handle raw executable binaries, resolve `$APPDIR`
paths, and use `ditto` for app bundle copying to avoid macOS "damaged
app" errors
([#&#8203;10626](https://redirect.github.com/jdx/mise/pull/10626) by
[@&#8203;arthurh4](https://redirect.github.com/arthurh4)).
- **config:** preserve set values in `mise config set` for
comma-separated set-typed settings
([#&#8203;10647](https://redirect.github.com/jdx/mise/pull/10647) by
[@&#8203;KrishRVH](https://redirect.github.com/KrishRVH)).
- **config:** render `task_config.includes` templates with resolved
`vars` ([#&#8203;10700](https://redirect.github.com/jdx/mise/pull/10700)
by [@&#8203;jdx](https://redirect.github.com/jdx)).
- **config:** support `required` validation and `redact = true` on
`[vars]`; render tool option templates recursively
([#&#8203;10697](https://redirect.github.com/jdx/mise/pull/10697) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **dotnet:** validate SDK installs with `dotnet --list-sdks` so
`global.json` roll-forward no longer causes false failures
([#&#8203;10691](https://redirect.github.com/jdx/mise/pull/10691) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **generate:** `mise generate tool-stub --lock` respects configured
`lockfile_platforms`
([#&#8203;10709](https://redirect.github.com/jdx/mise/pull/10709) by
[@&#8203;JamBalaya56562](https://redirect.github.com/JamBalaya56562)).
- **github:** handle missing/empty `url_api` in older lockfile entries,
falling back to the cached browser URL
([#&#8203;10703](https://redirect.github.com/jdx/mise/pull/10703) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **hooks:** set `MISE_INSTALLED_TOOLS=[]` on no-op installs so
`postinstall` always receives a valid JSON array
([#&#8203;10615](https://redirect.github.com/jdx/mise/pull/10615) by
[@&#8203;JamBalaya56562](https://redirect.github.com/JamBalaya56562)).
- **http:** don't let netrc credentials clobber explicit forge tokens on
un-redirected URLs, fixing private GitHub release asset downloads
([#&#8203;10713](https://redirect.github.com/jdx/mise/pull/10713) by
[@&#8203;yacchi](https://redirect.github.com/yacchi)).
- **lockfile:** merge platform data when a tool's options newly diverge
from an empty on-disk entry (e.g. java `shorthand_vendor`), preventing
checksum/URL loss
([#&#8203;10710](https://redirect.github.com/jdx/mise/pull/10710) by
[@&#8203;JamBalaya56562](https://redirect.github.com/JamBalaya56562)).
- **npm:** map `allow_builds` to npm 11.16+ `--allow-scripts` /
`--dangerously-allow-all-scripts` instead of forcing `--ignore-scripts`
([#&#8203;10690](https://redirect.github.com/jdx/mise/pull/10690) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **oci:** canonicalize install paths when rebasing `PATH`, fixing `mise
oci` on systems with symlinked `/home` (Bluefin/Silverblue)
([#&#8203;10624](https://redirect.github.com/jdx/mise/pull/10624) by
[@&#8203;salim-b](https://redirect.github.com/salim-b)).
- **oci:** account for darwin mode stripping in layer test expectations
([#&#8203;10681](https://redirect.github.com/jdx/mise/pull/10681) by
[@&#8203;laozc](https://redirect.github.com/laozc)).
- **ruby:** stop forcing `no-yjit` Ruby builds on older glibc
([#&#8203;10620](https://redirect.github.com/jdx/mise/pull/10620) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **sigstore:** retry GitHub attestation verification with the TUF trust
root after embedded-root failures; workflow mismatches remain
non-retryable
([#&#8203;10695](https://redirect.github.com/jdx/mise/pull/10695) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **task:** render monorepo subproject task templates with the
subproject's own `[env]`; broken subprojects no longer fail discovery
repo-wide
([#&#8203;10706](https://redirect.github.com/jdx/mise/pull/10706) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **task:** correct env used for the `task.show_full_cmd` setting
([#&#8203;10714](https://redirect.github.com/jdx/mise/pull/10714) by
[@&#8203;muzimuzhi](https://redirect.github.com/muzimuzhi)).
- **vfox:** Lua `os.getenv` now reads from mise's env table like
`cmd.exec`/`os.execute`
([#&#8203;10719](https://redirect.github.com/jdx/mise/pull/10719) by
[@&#8203;jdx](https://redirect.github.com/jdx)).
- **watch:** forward `--ignore`, `--ignore-file`, and `--print-events`
to watchexec
([#&#8203;10629](https://redirect.github.com/jdx/mise/pull/10629) by
[@&#8203;JamBalaya56562](https://redirect.github.com/JamBalaya56562)).
- **windows:** allow GHCUp to be installed on Windows via aqua
([#&#8203;10670](https://redirect.github.com/jdx/mise/pull/10670) by
[@&#8203;cprecioso](https://redirect.github.com/cprecioso)).
- **copr:** drop retired Fedora 42 chroots from the default build list
([#&#8203;10698](https://redirect.github.com/jdx/mise/pull/10698) by
[@&#8203;jdx](https://redirect.github.com/jdx)).

##### Security

- Ignore transitive `quick-xml` advisories RUSTSEC-2026-0194/-0195
pending upstream fixes
([#&#8203;10717](https://redirect.github.com/jdx/mise/pull/10717) by
[@&#8203;jdx](https://redirect.github.com/jdx)).

##### 💚 Sponsor mise

mise is built by [@&#8203;jdx](https://redirect.github.com/jdx) under
[**en.dev**](https://en.dev) — an independent studio making developer
tooling (mise, [aube](https://aube.en.dev/), and more). Development is
funded by sponsors.

If mise saves you or your team time, please consider sponsoring at
[en.dev](https://en.dev). Individual and company sponsorships keep mise
fast, free, and independent.

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 4am on Monday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/prometheus/client_java).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDIuMiIsInVwZGF0ZWRJblZlciI6IjQzLjI0Mi4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
@arnabnandy7 arnabnandy7 force-pushed the fix/native-histogram-bucket-resize-index branch from 5ec3d02 to 6e89c79 Compare July 3, 2026 12:51
@arnabnandy7 arnabnandy7 closed this Jul 3, 2026
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.

1 participant