Files
seaweedfs/weed
41f1c25d01 s3api: drop bucket size gauges on an instance that lost the metrics lock (#13019)
* s3api: drop bucket size gauges on an instance that lost the metrics lock

Only the S3 instance holding the s3.leader lock collects bucket sizes and
quota state, once a minute. An instance that loses the lock and keeps
running never clears what it set. bucketMetricTTLControl drops a bucket's
gauges only after 10 minutes without activity, and every request the
instance serves for the bucket counts as activity. So for the buckets
clients keep using through it, its bucket_size_bytes,
bucket_physical_size_bytes, bucket_object_count, bucket_quota_bytes and
bucket_read_only series stay at the values it collected last, next to the
new holder's current ones. Summing a gauge over instances counts those
buckets twice, and taking the max shows a bucket that has shrunk since at
its old size.

On every tick without the lock, reset these five gauges. Only the
holder's collection sets them, so an instance that never held the lock
loses nothing, and one that lost it stops reporting within a minute.

In a cluster with seven S3 instances, one kept 10 to 14 buckets at their
old values for four days after losing the lock; at one point the max
over instances put a bucket 37 TB above its size.

TestBucketSizeMetricsTickWithoutLockDropsGauges sets the gauges for two
buckets, checks that a tick with the lock leaves them, and that a tick
without it removes all five. Without the reset it fails for each gauge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: shorten the bucket size metrics lock-loss comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-11-26 08:31:16 -08:00
..
2026-04-14 20:48:24 -07:00
2026-04-23 10:05:51 -07:00