You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "zjncs (via GitHub)" <gi...@apache.org> on 2026/10/06 05:09:13 UTC

[PR] fix(settings): stop caching the parameterized data-source query [rocketmq-dashboard]

zjncs opened a new pull request, #5606:
URL: https://github.com/apache/rocketmq-dashboard/pull/5606

   Closes #5605
   
   ## Problem
   
   The paginated `listDataSources(search, type, page, pageSize)` overload carried the same `@Cacheable(DATA_SOURCE_CACHE)` as the full-list method, contradicting the comment that documents the cache as a cache of the **full list only**. Consequences:
   
   - the Spring cache key is `SimpleKey(search, type, page, pageSize)` — `search`/`type` are arbitrary caller strings on `GET /api/settings/datasources/page`, which is **not** admin-only, so any authenticated reader can drive it
   - the configured `ConcurrentMapCacheManager` has no TTL, size bound, or eviction (entries only clear on data-source create/update/delete)
   - every distinct search term permanently pins a `PageResult<DataSourceVO>` — DTOs carrying data-source auth fields (authType/username/password/bearerToken)
   
   ## Fix
   
   Remove the annotation from the parameterized overload only (the full-list method keeps it, and the write-path `@CacheEvict(allEntries=true)` methods continue to maintain it); leave a comment stating why the paged overload is intentionally uncached.
   
   ## Verification
   
   - New `SettingsServiceDataSourceCacheBoundTest` boots an `AnnotationConfigApplicationContext` registering the **production** `CacheConfig`:
     - control `fullDataSourceListIsCachedAsDocumented` — the full list is served once and cached (proves the harness is live); passes on master and with this change
     - `parameterizedDataSourceSearchMustNotAccumulatePermanentCacheEntries` — **FAILS on master** (50 permanent entries after 50 distinct searches: `Expecting empty but was: {SimpleKey [search-1, null, 1, 20]=PageResult@…, …}`), **PASSES with this change**
   - Regression: all existing settings suites green — `SettingsServiceTest` 43/43, `SettingsServiceCachingTest` 1/1, `SettingsControllerTest` 23/23, DTO/factory tests 5/5
   - Mutation check: reverting the annotation removal makes the new test fail again; restoring it passes
   
   ## Collision note
   
   `SettingsService.java` is touched by #4681 (hunks @394-440), #4708 (@325-340), #5484 (@160-170) — this change is confined to lines ~213-234, disjoint from all three with wide margins. `CacheConfig.java` and the new test file are untouched by any open PR.


-- 
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(settings): stop caching the parameterized data-source query [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on PR #5606:
URL: https://github.com/apache/rocketmq-dashboard/pull/5606#issuecomment-6076051068

   The finding is correct and well-argued: SettingsService.java:211-222 documents the cache as
   full-list-only, CacheConfig.java:50-51 returns a bare ConcurrentMapCacheManager with no TTL or
   bound, and GET /api/settings/datasources/page is not in AuthInterceptor.isAdminOnlyGetPath
   (:174-183), so any authenticated reader can pin one PageResult per distinct search term. The
   regression counts you cite (43/1/23/5) all check out, and SettingsServiceCachingTest genuinely
   stays green because it calls each key once.
   Two things block it as submitted. First, both new @Test methods must end with "Test"
   (fullDataSourceListIsCachedAsDocumentedTest /
   parameterizedDataSourceSearchMustNotAccumulatePermanentCacheEntriesTest) - the repo convention
   applies in full to new files, and the sibling SettingsServiceCachingTest already follows it.
   Second, both files lost their trailing newline.
   Also please correct the severity claim: the cached type DataSourceVO has no
   authType/username/password/bearerToken fields (see DataSourceVO.java:31-42 - key, name, type,
   url, auth, status, instanceIds; bearerToken only exists on DataSourceTestDTO:40, which is never
   cached). The unbounded-heap argument stands on its own; the credential-exposure framing does not.
   Minor: use imports for @Configuration/@Bean instead of fully-qualified inline annotations, as
   SettingsServiceCachingTest does. And this PR targets master, which is 60 commits behind the
   rocketmq-studio integration branch - please retarget.
   


-- 
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(settings): stop caching the parameterized data-source query [rocketmq-dashboard]

Posted by "zjncs (via GitHub)" <gi...@apache.org>.
zjncs commented on PR #5606:
URL: https://github.com/apache/rocketmq-dashboard/pull/5606#issuecomment-6077855617

   Thank you for the thorough review — all four points addressed in 9f6f38c:
   
   1. **Test method names** now end with `Test` (`fullDataSourceListIsCachedAsDocumentedTest` / `parameterizedDataSourceSearchMustNotAccumulatePermanentCacheEntriesTest`).
   2. **Trailing newlines** — verified present in both committed files.
   3. **Severity corrected**: the credential-exposure framing is removed from both the product comment and the test javadoc. You're right that `DataSourceVO` carries no `authType`/`username`/`password`/`bearerToken` (those live on `DataSourceTestDTO`, which is never cached). The argument stands on the unbounded-heap side alone, and the PR description claim is withdrawn.
   4. **`@Configuration`/`@Bean`** now imported rather than fully qualified.
   
   **Retargeted to `rocketmq-studio`** as requested.
   
   Verification: `mvn test -Dtest=SettingsServiceDataSourceCacheBoundTest` green with checkstyle clean — the control test proves the full-list cache still works (repository hit once), the bound test proves 50 distinct searches leave zero permanent entries.


-- 
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(settings): stop caching the parameterized data-source query [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed pull request #5606: fix(settings): stop caching the parameterized data-source query
URL: https://github.com/apache/rocketmq-dashboard/pull/5606


-- 
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(settings): stop caching the parameterized data-source query [rocketmq-dashboard]

Posted by "zjncs (via GitHub)" <gi...@apache.org>.
zjncs commented on PR #5606:
URL: https://github.com/apache/rocketmq-dashboard/pull/5606#issuecomment-6076366599

   @lizhimins Thank you for the thorough review — all four points are addressed in the re-submission #5775 (GitHub won't let the author reopen a maintainer-closed PR, and a closed PR's base can't be changed, so a new PR was the only path):
   
   1. Both test methods renamed to end with `Test` (`fullDataSourceListIsCachedAsDocumentedTest` / `parameterizedDataSourceSearchMustNotAccumulatePermanentCacheEntriesTest`);
   2. Trailing newlines restored on both files;
   3. The credential-exposure framing is dropped everywhere (comment, test javadoc, and PR description) — you're right that `DataSourceVO` carries no credential fields; the unbounded-heap argument stands on its own;
   4. `@Configuration`/`@Bean` moved to imports, matching `SettingsServiceCachingTest`.
   
   Rebased onto `rocketmq-studio` (c99b9ad5) where the finding still reproduces; verification rerun there: 3/3 green including the sibling convention test, and the mutation check (restoring only the `@Cacheable`) fails with `Tests run: 2, Failures: 1`. Sorry for the stale-`master` targeting — we've fixed our process to always base dashboard PRs on `rocketmq-studio` going forward.


-- 
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