Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsdb/wlog: Only treat unknown record types as failure #14042

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

aknuds1
Copy link
Contributor

@aknuds1 aknuds1 commented May 3, 2024

I noticed that tsdb/wlog.Watcher.readSegmentForGC treats e.g. histogram records as unsupported, and counts them against w.recordDecodeFailsMetric. I propose that we instead do this only for the record.Unknown type.

@aknuds1 aknuds1 requested a review from jesusvazquez as a code owner May 3, 2024 08:57
@aknuds1 aknuds1 force-pushed the arve/wlog-histograms branch 2 times, most recently from a328f89 to c0dc3b5 Compare May 6, 2024 09:19
Copy link
Collaborator

@machine424 machine424 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

case record.Tombstones:

default:
case record.Unknown:
// Could be corruption, or reading from a WAL from a newer Prometheus.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t grasp this comment from the initial reading, does it mean?

Suggested change
// Could be corruption, or reading from a WAL from a newer Prometheus.
// Could be corruption, or version incompatibility between the WAL and Prometheus.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep the original comment personally, since it's from before this PR. To me it's also perfectly understandable at least.

case record.Tombstones:

default:
case record.Unknown:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only minor downside that I can anticipate is that if we introduce a new type in the future that necessitates special handling here and we neglect to include it, recordsReadMetric (via a dashboard or an alert, if applicable) will no longer be capable of alerting us to the oversight. However, I believe we’ll eventually figure that out in another way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't see any problem with defaulting to ignore records at least, since the logic is explicitly to only handle series. It's better to not reimplement dec.Type's logic for detecting supported record types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it some more, is it at all possible certain record types (MmapMarkers and Metadata, I assume that HistogramSamples and FloatHistogramSamples were just not added to this logic) should not be encountered here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bboreham I think you wrote this code, can you clarify?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the code was copy-pasted from

switch dec.Type(rec) {
, with processing for non-series removed.

I haven't been involved in work to add histograms or metadata.

More broadly, I would like the WAL to be a bit more backwards-compatible, e.g. to have a version number so we know what we're supposed to be doing, but I couldn't see a way to add that backwards-compatibly.

@bboreham
Copy link
Member

bboreham commented May 9, 2024

I would expect the same change at

default:
// Could be corruption, or reading from a WAL from a newer Prometheus.
w.recordDecodeFailsMetric.Inc()

@aknuds1
Copy link
Contributor Author

aknuds1 commented May 9, 2024

I would expect the same change at

@bboreham thanks, I didn't notice the similarity. I can make a corresponding change there (if it makes sense, will have to think it through).

@bboreham
Copy link
Member

How does this PR relate to #13181 ?

@aknuds1
Copy link
Contributor Author

aknuds1 commented May 27, 2024

How does this PR relate to #13181 ?

I'll try to review that PR, wasn't known to me.

@aknuds1
Copy link
Contributor Author

aknuds1 commented May 27, 2024

How does this PR relate to #13181 ?

@bboreham after reviewing that PR, as far as I can tell these two PRs are orthogonal to each other.

@aknuds1
Copy link
Contributor Author

aknuds1 commented May 28, 2024

I would expect the same change at

@bboreham I've made the change also there, PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants