series/values: fix negative relative time offsets and async crash on …#2507
Open
tallpsmith wants to merge 1 commit intoperformancecopilot:mainfrom
Open
series/values: fix negative relative time offsets and async crash on …#2507tallpsmith wants to merge 1 commit intoperformancecopilot:mainfrom
tallpsmith wants to merge 1 commit intoperformancecopilot:mainfrom
Conversation
…bad input PM_MAX_TIME_T as the end-time sentinel in parsetime() caused __pmtimespecParse() to skip the negative-relative branch entirely, silently rejecting "-30s", "-7d" etc. Use wall clock instead. Add early abort in pmSeriesValues() before async phases are launched so parse errors invoke on_done cleanly rather than propagating corrupt timing state into Redis queries. Fixes: performancecopilot#2503
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2503 — three tiers of breakage in
/series/valuestime parameter handling.Root cause (Tier 1/2):
parsetime()insrc/libpcp_web/src/query.cusedPM_MAX_TIME_Tas the end-time sentinel when calling__pmtimespecParse(). Becausertime.c:656gates the negative-relative branch onend.tv_sec < PM_MAX_TIME_T, any negative offset (-30s,-2m,-1h,-7d) fell through toglib_get_date()which cannot handle them. Fix: use the current wall-clock time (pmtimespecNow()) so the negative-relative branch is taken correctly.Crash path (Tier 2/3):
pmSeriesValues()launched the async Redis pipeline even wheninitSeriesGetValues()had already setbaton->errordue to a parse failure. Corrupt/zero timing state then propagated into Redis queries, causing crashes. Fix: early abort — callseries_query_finished()to invokeon_donewith the error and free the baton cleanly before any async phase is started.Test plan
qa/src/series_time_parse_test.cbuilds and passes (no Redis/pmcd required)PM_MAX_TIME_Tsentinel rejects-30s,-7dend=nowcorrectly parses-30s,-2m,-1h,-7dwith ±1s tolerance+30s,30s) still work2024-01-15T10:30:00Zsurvives__pmtimespecParse()without crashingGET /series/values?series=<id>&start=-30sreturns data (not a disconnect)