Repository navigation
Conversation
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
| // and shipped and dbs[0] is moved to dbs[1]. During this process, | ||
| // there is only 1 TSDB ingesting old data, so there can be gaps till the compaction | ||
| // and shipping is going on. | ||
| // TODO(codesome): Avoid gaps by using a separate queue to compact and ship blocks. |
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
d67173e to
6d68cb6
Compare
Signed-off-by: Ganesh Vernekar <[email protected]>
6d68cb6 to
5886802
Compare
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
pstibrany
left a comment
There was a problem hiding this comment.
This code is quite difficult to digest for me. I'm wondering what would help me to understand it better:
-
Avoid backward-dependancies from new types to ingester if possible. In general, if type
Acreates instances of typeB, thenBshould not need to know aboutA: insteadAneeds to pass everything thatBneeds to it. I know ingester code doesn't always fit into this. :( -
I think naming-wise,
dbs[0]anddbs[1]can perhaps be improved (eg. "older", "newer"?) -
repeated 1-hour check wasn't clear to me at first.
I need to spend more time with this PR to fully understand all the details. It seems like it would work, but it adds a lot of complexity too.
| startTime := model.Time(start).Time().UTC() | ||
| endTime := model.Time(end).Time().UTC() | ||
|
|
||
| return fmt.Sprintf( |
There was a problem hiding this comment.
"<start>-<end>" as unix timestamps may be easier to work with
There was a problem hiding this comment.
In case we have to debug, would it not be easier if the name told the exact hours without needing a manual translation? (thinking of the case where there might be multiple backfill TSDBs piled up due to various reasons).
There was a problem hiding this comment.
Yes, that's true, although there is a lot of precedent for unix timestamps at many places – eg. min/max time in meta.json of TSDB block, even block ID (ULID) has embedded timestamp in it. Your choice, this isn't a showstopper for me.
That was the first thing I tried. But it turned out to be a lot of duplicated code and maybe also makes it harder to approach the review. So I resorted to using an array and use the index to generalise the code. I will check again if explicit variable could be used after some simplifications now (and maybe more comments for context). |
Signed-off-by: Ganesh Vernekar <[email protected]>
Need the ingester in |
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
ddd3473 to
639242b
Compare
| } | ||
|
|
||
| // Fast path to not take the lock. | ||
| if a.newerAppender != nil && s.TimestampMs >= a.newerAppender.start && s.TimestampMs < a.newerAppender.end { |
There was a problem hiding this comment.
Is it safe to access a.newerAppender and a.olderAppender, given their references may be replaced any time (and when they're replaced, a lock is used)?
There was a problem hiding this comment.
Yes, it's safe. Note that it is 1 appender per v2Push call and not shared across multiple push. The idea here is that the goroutine which is getting the appender will use it sequentially (which is the case in v2Push, each sample is iterated sequentially). So, while the DBs can be started in parallel which is protected by the lock, it is safe to access newerAppender and olderAppender without lock as they are the part of the appender and not the backfillTSDB.
| } | ||
| startAppend := time.Now() | ||
|
|
||
| cachedRef, cachedRefExists := db.refCache.Ref(startAppend, client.FromLabelAdaptersToLabels(la)) |
There was a problem hiding this comment.
To my understanding, db.refCache is shared across all TSDBs (main + 2 backfill) but is it safe to be shared?
There was a problem hiding this comment.
The backfill TSDBs themselves are userTSDB and have their own refCache (each backfill TSDB getting one). They don't have any access to the main TSDB.
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
|
|
||
| // We could use RLock here to check the TSDBs, but because we create new TSDB if none exists, | ||
| // it's easier and cleaner to handle races by taking the write lock. | ||
| // TODO(codesome): IMPORTANT: fix the issue where the compaction moves the TSDB around between 2 appends to avoid using wrong appenders in older and newer spots. |
There was a problem hiding this comment.
Regarding this // TODO(codesome): IMPORTANT: fix the issue where the compaction moves the TSDB around between 2 appends to avoid using wrong appenders in older and newer spots., I think this is fine with a check for the appender being nil to not overwrite it and lose data.
Reasons:
- If the older TSDB moved (i.e. outside of backfill age), that means the sample is not eligible anyway for ingestion as it went out of backfill age. So it is fine to fail the append.
- If the newer TSDB moved to the older spot, the new appender will be for the same TSDB as before and wont be an issue ingesting to it if the sample falls in that TSDB.
- If the newer TSDB moved to the older spot and the new sample incoming belongs to the newer TSDB to be created, then we fail that append here which will be retried later.
So, no data loss because of the re-try of Prometheus remote-write. This is a tradeoff for a whole lot complexity it would bring to handle moving appenders with TSDBs. If it turns out to be a problem, we can iterate on it later.
There was a problem hiding this comment.
I will update the comment (with TODO) explaining the case and that it is fine.
Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
2dbef45 to
4631092
Compare
|
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
|
Still super valid. Offline discussions are on-going. |
|
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
|
Nope nope, still valid |
|
Closing for now, since we're currently considering a different solution. |
What this PR does:
Supersedes #2819. I chose to open a new PR so that I can have the old one as reference for some parts.
This implements the updated design as described in #2366 (comment)
Which issue(s) this PR fixes:
Fixes #2366
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]TODO in future PRs