You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sql/stats: avoid mutating input buckets in stripOuterBuckets
This commit changes `stripOuterBuckets` to modify and return a copy of
the given histogram buckets if it finds outer buckets to remove.
Previously, we would mutate the caller's histograms with leading outer
buckets in-place by zeroing the range counts on the first non-outer
bucket. This effectively corrupts the first histogram bucket in stats
passed in from the stats cache.
Although this bug has existed since 90e311d (which zeroes the first
buckets range counts), it would only impact full statistics that we
tried merging with partial stats, as that was the only case in which
`stripOuterBuckets` was called. The surface area of this bug increased
after db9a344, which calls `stripOuterBuckets` on every full statistic,
regardless of whether we end up merging it with partial stats or not.
Fixes: #155184
Release note (bug fix): Previously, we could corrupt the first bucket of
table statistic histograms in certain cases, causing underestimates for
range counts near the lower end of the domain, which is now fixed.
0 commit comments