-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Compaction limits #8348
Compaction limits #8348
Conversation
b969673
to
7c90c78
Compare
@benbjohnson Found a bug while testing and pushed up a fix. I also reworked the |
dc4c31f
to
053064d
Compare
@jwilder 👍 |
Compactions are enabled as soon as the shard is opened. This can slow down startup or cause the system to spike in CPU usage at startup if many shards need to be compacted. This now delays compactions until after they are loaded.
This limit allows the number of concurrent level and full compactions to be throttled. Snapshot compactions are not affected by this limit as then need to run continously. This limit can be used to control how much CPU is consumed by compactions. The default is to limit to the number of CPU available.
The compactor prevents the same file from being compacted by different compaction runs, but it can result in warning errors in the logs that are confusing. This adds compaction plan tracking to the planner so that files are only part of one plan at a given time.
Each shard has a number of goroutines for compacting different levels of TSM files. When a shard goes cold and is fully compacted, these goroutines are still running. This change will stop background shard goroutines when the shard goes cold and start them back up if new writes arrive.
The monitor goroutine ran for each shard and updated disk stats as well as logged cardinality warnings. This goroutine has been removed by making the disks stats more lightweight and callable direclty from Statisics and move the logging to the tsdb.Store. The latter allows one goroutine to handle all shards.
This was causing a shard to appear idle when in fact a snapshot compaction was running. If the time was write, the compactions would be disabled and the snapshot compaction would be aborted.
Index.ForEachMeasurementTagKey held an RLock while call the fn, if the fn made another call into the index which acquired an RLock and after another goroutine tried to acquire a Lock, it would deadlock.
053064d
to
7371f10
Compare
Since this is called more frequently now, the cleanup func was invoked quite a bit which makes several syscalls per shard. This should only be called the first time compactions are disabled.
Avoids some extra allocations.
I am still facing the issue. I went through the whole thread in #7640 . I could only understand to change the duration of my shards.,which i already did. But no much changes yet. Please advice. I can provide any sort of details needed. |
Required for all non-trivial PRs
This change adds a new limit to control how many concurrent full/level compactions can run at one time. It also stops background compaction goroutines for cold shards.
max-concurrent-compactions
can be set to limit the number of full and level compactions that run concurrently. This limit does not apply to snapshot compactions as they must run to avoid filling the cache. A value of0
, default, sets the limit toruntime.GOMAXPROCS(0)
. Any value greater than 0 will limit compactions to that number. Compactions that are scheduled to run when the limit is met, will block until one completes. This limit can be used to throttle CPU usage due to many concurrent compactions.Compactor
which would keep track of which files are currently being compacted. If a duplicate file was seen, the second compaction would be aborted leading to messages as seen in move some compaction logs to trace level #7425. The planner was updated to keep track of what files have been assigned to plans to prevent plans being returned with overlapping files. move some compaction logs to trace level #7425 should not occur now, but the safeguards in theCompactor
are still in place.tmp
files would not be cleaned up when an error occurred during a compaction. These are now removed.monitor
goroutine per shard has been removed and handled by a single goroutine for all shards on the store.Cache.Size
didn't include the snapshot size which cause the size to be misreported.Fixes #7425 #8276 #8123