Skip to content

Commit

Permalink
[COMMENT] TSDB: Document assumptions about what needs locking in memS…
Browse files Browse the repository at this point in the history
…eries

Signed-off-by: Bryan Boreham <[email protected]>
  • Loading branch information
bboreham committed May 9, 2024
1 parent 016135c commit 9c45470
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tsdb/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -2120,8 +2120,7 @@ func (s sample) Type() chunkenc.ValueType {
// memSeries is the in-memory representation of a series. None of its methods
// are goroutine safe and it is the caller's responsibility to lock it.
type memSeries struct {
sync.Mutex

// Members up to the Mutex are not changed after construction, so can be accessed without a lock.
ref chunks.HeadSeriesRef
lset labels.Labels
meta *metadata.Metadata
Expand All @@ -2133,6 +2132,10 @@ type memSeries struct {
// Value returned by secondary hash function.
secondaryHash uint32

sync.Mutex

// Everything after here should only be accessed with the lock.

// Immutable chunks on disk that have not yet gone into a block, in order of ascending time stamps.
// When compaction runs, chunks get moved into a block and all pointers are shifted like so:
//
Expand Down

0 comments on commit 9c45470

Please sign in to comment.