DB handles reads and writes of time series falling into a hashed partition of a seriedb.
| 293 | // DB handles reads and writes of time series falling into |
| 294 | // a hashed partition of a seriedb. |
| 295 | type DB struct { |
| 296 | dir string |
| 297 | locker *tsdbutil.DirLocker |
| 298 | |
| 299 | logger *slog.Logger |
| 300 | metrics *dbMetrics |
| 301 | opts *Options |
| 302 | chunkPool chunkenc.Pool |
| 303 | compactor Compactor |
| 304 | blocksToDelete BlocksToDeleteFunc |
| 305 | |
| 306 | // mtx must be held when modifying the general block layout or lastGarbageCollectedMmapRef. |
| 307 | mtx sync.RWMutex |
| 308 | blocks []*Block |
| 309 | |
| 310 | // The last OOO chunk that was compacted and written to disk. New queriers must not read chunks less |
| 311 | // than or equal to this reference, as these chunks could be garbage collected at any time. |
| 312 | lastGarbageCollectedMmapRef chunks.ChunkDiskMapperRef |
| 313 | |
| 314 | head *Head |
| 315 | |
| 316 | compactc chan struct{} |
| 317 | donec chan struct{} |
| 318 | stopc chan struct{} |
| 319 | |
| 320 | // cmtx ensures that compactions and deletions don't run simultaneously. |
| 321 | cmtx sync.Mutex |
| 322 | |
| 323 | // autoCompactMtx ensures that no compaction gets triggered while |
| 324 | // changing the autoCompact var. |
| 325 | autoCompactMtx sync.Mutex |
| 326 | autoCompact bool |
| 327 | |
| 328 | // retentionMtx protects access to retention configuration values that can |
| 329 | // be updated at runtime through config file changes. |
| 330 | retentionMtx sync.RWMutex |
| 331 | |
| 332 | // Cancel a running compaction when a shutdown is initiated. |
| 333 | compactCancel context.CancelFunc |
| 334 | |
| 335 | // timeWhenCompactionDelayStarted helps delay the compactions start time. |
| 336 | timeWhenCompactionDelayStarted time.Time |
| 337 | |
| 338 | // oooWasEnabled is true if out of order support was enabled at least one time |
| 339 | // during the time TSDB was up. In which case we need to keep supporting |
| 340 | // out-of-order compaction and vertical queries. |
| 341 | oooWasEnabled atomic.Bool |
| 342 | |
| 343 | // lastHeadCompactionTime is the last wall clock time when the head block compaction was started, |
| 344 | // irrespective of success or failure. This does not include out-of-order compaction and stale series compaction. |
| 345 | lastHeadCompactionTime time.Time |
| 346 | |
| 347 | writeNotified wlog.WriteNotified |
| 348 | |
| 349 | registerer prometheus.Registerer |
| 350 | |
| 351 | blockQuerierFunc BlockQuerierFunc |
| 352 |
nothing calls this directly
no outgoing calls
no test coverage detected