From 136f8b0ebb13180bb1ff8a260728157f785d6ea8 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 13 Sep 2022 10:11:03 +0100 Subject: [PATCH] tsdb: comment reason for isolation tracking reads (#11301) I find it useful to know why a restriction exists, to check whether that reason still applies, or in which other places it might apply. This is based on the note here: https://github.com/prometheus/prometheus/pull/9270#pullrequestreview-743820956 on the PR where the original comment was added. Signed-off-by: Bryan Boreham Signed-off-by: Bryan Boreham --- tsdb/isolation.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsdb/isolation.go b/tsdb/isolation.go index 4919bfe915..46d13edf81 100644 --- a/tsdb/isolation.go +++ b/tsdb/isolation.go @@ -122,7 +122,8 @@ func (i *isolation) State(mint, maxt int64) *isolationState { i.appendMtx.RLock() // Take append mutex before read mutex. defer i.appendMtx.RUnlock() - // We need to track the reads even when isolation is disabled. + // We need to track reads even when isolation is disabled, so that head + // truncation can wait till reads overlapping that range have finished. isoState := &isolationState{ maxAppendID: i.appendsOpenList.appendID, lowWatermark: i.appendsOpenList.next.appendID, // Lowest appendID from appenders, or lastAppendId.