Skip to content

Commit e372812

Browse files
committed
Update comments for methods that require a lock
Signed-off-by: Lukasz Mierzwa <l.mierzwa@gmail.com>
1 parent a1740cd commit e372812

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tsdb/db.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ func (db *DB) CompactOOOHead(ctx context.Context) error {
13681368
// Callback for testing.
13691369
var compactOOOHeadTestingCallback func()
13701370

1371+
// The db.cmtx mutex should be held before calling this method.
13711372
func (db *DB) compactOOOHead(ctx context.Context) error {
13721373
if !db.oooWasEnabled.Load() {
13731374
return nil
@@ -1422,6 +1423,7 @@ func (db *DB) compactOOOHead(ctx context.Context) error {
14221423

14231424
// compactOOO creates a new block per possible block range in the compactor's directory from the OOO Head given.
14241425
// Each ULID in the result corresponds to a block in a unique time range.
1426+
// The db.cmtx mutex should be held before calling this method.
14251427
func (db *DB) compactOOO(dest string, oooHead *OOOCompactionHead) (_ []ulid.ULID, err error) {
14261428
start := time.Now()
14271429

@@ -1466,7 +1468,7 @@ func (db *DB) compactOOO(dest string, oooHead *OOOCompactionHead) (_ []ulid.ULID
14661468
}
14671469

14681470
// compactHead compacts the given RangeHead.
1469-
// The compaction mutex should be held before calling this method.
1471+
// The db.cmtx should be held before calling this method.
14701472
func (db *DB) compactHead(head *RangeHead) error {
14711473
uids, err := db.compactor.Write(db.dir, head, head.MinTime(), head.BlockMaxTime(), nil)
14721474
if err != nil {
@@ -1492,7 +1494,7 @@ func (db *DB) compactHead(head *RangeHead) error {
14921494
}
14931495

14941496
// compactBlocks compacts all the eligible on-disk blocks.
1495-
// The compaction mutex should be held before calling this method.
1497+
// The db.cmtx should be held before calling this method.
14961498
func (db *DB) compactBlocks() (err error) {
14971499
// Check for compactions of multiple blocks.
14981500
for {
@@ -1549,6 +1551,7 @@ func getBlock(allBlocks []*Block, id ulid.ULID) (*Block, bool) {
15491551
}
15501552

15511553
// reload reloads blocks and truncates the head and its WAL.
1554+
// The db.cmtx mutex should be held before calling this method.
15521555
func (db *DB) reload() error {
15531556
if err := db.reloadBlocks(); err != nil {
15541557
return fmt.Errorf("reloadBlocks: %w", err)
@@ -1565,6 +1568,7 @@ func (db *DB) reload() error {
15651568

15661569
// reloadBlocks reloads blocks without touching head.
15671570
// Blocks that are obsolete due to replacement or retention will be deleted.
1571+
// The db.cmtx mutex should be held before calling this method.
15681572
func (db *DB) reloadBlocks() (err error) {
15691573
defer func() {
15701574
if err != nil {

0 commit comments

Comments
 (0)