This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 39e1bae11 fix(audit): invalidate the filter cache when a cleanup 
deletes rows (#6935)
39e1bae11 is described below

commit 39e1bae1114eaa49fc425b88ac53aacb340adbe1
Author: bai mengxuan <[email protected]>
AuthorDate: Fri Nov 27 12:23:36 2026 +0800

    fix(audit): invalidate the filter cache when a cleanup deletes rows (#6935)
---
 .../studio/ops/audit/MybatisPlusAuditRepository.java     |  6 ++++++
 .../studio/ops/audit/MybatisPlusAuditRepositoryTest.java | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/ops/audit/MybatisPlusAuditRepository.java
 
b/server/src/main/java/org/apache/rocketmq/studio/ops/audit/MybatisPlusAuditRepository.java
index 2a1cccf02..6ae3bf3cd 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/ops/audit/MybatisPlusAuditRepository.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/ops/audit/MybatisPlusAuditRepository.java
@@ -242,6 +242,12 @@ public class MybatisPlusAuditRepository implements 
AuditRepository {
                 break;
             }
         }
+        if (totalDeleted > 0) {
+            // The filter dropdowns are cached for a short while; a cleanup 
that removed rows must
+            // not keep offering the values those rows carried (the page 
refetches the options right
+            // after a cleanup, and that refetch would be answered from this 
cache).
+            cachedFilterOptions = null;
+        }
         return totalDeleted;
     }
 
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/ops/audit/MybatisPlusAuditRepositoryTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/ops/audit/MybatisPlusAuditRepositoryTest.java
index aa78663b3..d0ce11203 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/ops/audit/MybatisPlusAuditRepositoryTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/ops/audit/MybatisPlusAuditRepositoryTest.java
@@ -218,6 +218,22 @@ class MybatisPlusAuditRepositoryTest {
         assertThat(deleted).isEqualTo(4);
     }
 
+    @Test
+    void deleteBeforeInvalidatesCachedFilterOptionsTest() {
+        when(auditMapper.selectMaps(any(Wrapper.class))).thenReturn(List.of());
+        
when(auditMapper.selectList(any())).thenReturn(List.of(auditRecord(1L)));
+        when(auditMapper.deleteByIds(List.of(1L))).thenReturn(1);
+
+        repository.findFilterOptions();
+        repository.deleteBefore(LocalDateTime.of(2026, 8, 1, 0, 0), 10, 1);
+        repository.findFilterOptions();
+
+        // The cleanup removed the rows those options came from, so the page's 
post-cleanup refetch
+        // must reach the mapper again instead of reading the 30-second cache.
+        verify(auditMapper, times(2)).selectMaps(any(Wrapper.class));
+        verify(auditMapper).deleteByIds(List.of(1L));
+    }
+
     @Test
     void saveInvalidatesCachedFilterOptionsTest() {
         when(auditMapper.selectMaps(any(Wrapper.class))).thenReturn(List.of());

Reply via email to