Repository navigation
fix(dashboard): eliminate time range race condition with requestId tagging (#590) #600
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ interface CpuState { | |
| data: CpuDataPoint[] | ||
| error?: JSONObject | null | ||
| loading?: boolean | ||
| requestId?: string | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -34,23 +35,28 @@ const cpuSlice = createSlice({ | |
| initialState: initialCpuState, | ||
| reducers: { | ||
| cpuUsageRequested: (state, action) => { | ||
| const { connectionId } = action.payload | ||
| const { connectionId, requestId } = action.payload | ||
| if (!state[connectionId]) { | ||
| state[connectionId] = { | ||
| data: [], | ||
| loading: false, | ||
| } | ||
| } | ||
| state[connectionId].loading = true | ||
| state[connectionId].requestId = requestId | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tag the epic's CPU and memory requests so their responses can be matched. The Give the epic dispatches a Suggested fix
|
||
| }, | ||
| cpuUsageFulfilled: (state, action) => { | ||
| const { connectionId, parsedResponse } = action.payload | ||
| const { connectionId, parsedResponse, requestId } = action.payload | ||
| if (!state[connectionId]) { | ||
| state[connectionId] = { | ||
| data: [], | ||
| loading: false, | ||
| } | ||
| } | ||
| // Drop out-of-order response if a newer request was dispatched | ||
| if (requestId && state[connectionId].requestId && requestId !== state[connectionId].requestId) { | ||
| return | ||
| } | ||
| // Validate that parsedResponse is an array | ||
| if (Array.isArray(parsedResponse)) { | ||
| state[connectionId].data = parsedResponse | ||
|
|
@@ -62,8 +68,11 @@ const cpuSlice = createSlice({ | |
| state[connectionId].loading = false | ||
| }, | ||
| cpuUsageError: (state, action) => { | ||
| const { connectionId, error } = action.payload | ||
| const { connectionId, error, requestId } = action.payload | ||
| if (state[connectionId]) { | ||
| if (requestId && state[connectionId].requestId && requestId !== state[connectionId].requestId) { | ||
| return | ||
| } | ||
| state[connectionId].error = error | ||
| state[connectionId].loading = false | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Readiness refetch overwrites a picker-selected range with one hour.
The metrics readiness retry dispatches one-hour CPU and memory requests when
setDataarrives (valkeyEpics.ts:720-721). The dashboard picker can issue a different range while those retries are pending. Each range change dispatches a new request with its ownrequestId(cpu-memory-usage.tsx:34-43). If the user selects 24 hours before readiness completes, the one-hour request replaces that ID. The later 24-hour responses no longer match the latest ID and are dropped. The chart can then show one-hour data under the 24-hour picker until the user changes the range again.The readiness refetch must request the range that the picker currently shows, or it must not replace a picker request issued after the retry started. The epic cannot read that range today because
cpuTimeRangeandmemoryTimeRangeare local state inCpuMemoryUsage(cpu-memory-usage.tsx:26-27). The mechanism for sharing that state is an open design choice.