You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "unbridled-41 (via GitHub)" <gi...@apache.org> on 2026/09/15 11:42:07 UTC
[PR] fix(producer): invalidate the in-flight connection query when the topic changes [rocketmq-dashboard]
unbridled-41 opened a new pull request, #4322:
URL: https://github.com/apache/rocketmq-dashboard/pull/4322
Fixes #4168 (resubmission of #4169 per @lizhimins's review).
## Problem / Evidence
On the Producer page, `handleTopicChange` (`web/src/pages/studio/Producer.tsx`) only resets the producer-group suggestions, so after switching the selected topic the connection table and readiness banner keep showing the previous topic's results. It also never invalidates a pending query, so the exact race the state reset targets is left open: a slow in-flight response repopulates what a scope change just cleared.
## Root cause / Fix
Per the review on #4169: clearing visible state without bumping `queryRequestIdRef` / clearing `queryInFlightRef` (as `handleInstanceChange` does) does not hold under the race.
This PR extracts one shared `resetConnectionQuery` helper that
- bumps `queryRequestIdRef.current` so the pending response's `requestId` guard fails,
- clears `queryInFlightRef.current` so a fresh query is not blocked,
- resets `connectionList`, `connectionSummary`, and `loading`.
`handleInstanceChange` now uses the helper (replacing its inline ref bumps/clears — behavior unchanged), and `handleTopicChange` uses it too, so a topic change invalidates the in-flight query and drops the previous topic's visible results exactly like an instance change does. The export button's existing `disabled={connectionList.length === 0}` guard keeps stale rows from being exported until a new query runs.
## Tests
One real race regression replaces the previous PR's export test (dropped as requested — its mock omitted `topic`/`producerGroup`, which the server always populates, so the export fallback it asserted is unreachable in production):
- `discards a slow connection response after the topic changes`: submit a query for topic A whose response is held pending, switch the topic to B while it is in flight, then resolve A's response — the stale row and readiness banner must not appear, and a fresh query for B must run (proving the in-flight slot was released).
- Red on unmodified base `25132a0d` (fix stashed): `FAIL … expected document not to contain element, found <span>生产者连接健康</span>` — the resolved stale response was written back after the switch.
- Green after the fix: `npx vitest run src/pages/studio/__tests__/Producer.test.tsx` → `Test Files 1 passed (1)`, `Tests 14 passed (14)` (13 pre-existing + 1 new).
- Full web suite: two runs → `3 failed | 117 passed` and `2 failed | 118 passed`; the failing set differs per run (`BrokerCluster`/`ConsumerPage`/`NotificationDeliveriesPage`/`MetricsExplorer`), and every one of those files passes in isolation (`BrokerCluster` 15 passed, `ConsumerPage`+`NotificationDeliveriesPage`+`MetricsExplorer` 59+25 passed) — the documented full-suite parallel-load flakiness, none touched by this change.
- `eslint` clean on both changed files (also enforced by the pre-commit `lint-staged` hook), `tsc --noEmit` clean, `vite build` succeeds (`✓ built in 8.63s`).
## Risk
Low. The helper is the existing `handleInstanceChange` invalidation sequence moved into a shared function; `handleTopicChange` additionally gains the same invalidation. Users who relied on switching topics while keeping the old table on screen now see an empty table (export disabled) until they run a new query — the same behavior an instance switch already produces.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(producer): invalidate the in-flight connection query when the topic changes [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed pull request #4322: fix(producer): invalidate the in-flight connection query when the topic changes
URL: https://github.com/apache/rocketmq-dashboard/pull/4322
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(producer): invalidate the in-flight connection query when the topic changes [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on PR #4322:
URL: https://github.com/apache/rocketmq-dashboard/pull/4322#issuecomment-5694561656
Merged as part of #4331 — squashed into `rocketmq-studio` as `6334f9238`.
Your change here (invalidating the in-flight connection query when the topic changes) is included.
We grouped 11 of your related front-end fixes into a single commit so the history stays reviewable; the other PRs in the group are closed with the same note. Everything was cherry-picked onto the current baseline with you kept as the author, and your tests came along with the change.
Thanks for the consistently well-tested patches.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org