fix: handle backend issue list regressions

This commit is contained in:
richjohnrambo
2026-09-30 15:35:03 +08:00
parent 7685fb0c02
commit 99ae6328ff
8 changed files with 207 additions and 5 deletions
+19 -1
View File
@@ -1411,7 +1411,8 @@ func (r *redisGroupMessageRuntime) hotSeqIDs(tenantID types.TenantID, topic stri
if err != nil {
return nil, false, err
}
if len(raw) < limit {
expected := hotSeqExpectedCount(opts, limit)
if len(raw) < expected {
return nil, false, nil
}
seqs := make([]int64, 0, len(raw))
@@ -1425,6 +1426,23 @@ func (r *redisGroupMessageRuntime) hotSeqIDs(tenantID types.TenantID, topic stri
return seqs, true, nil
}
func hotSeqExpectedCount(opts *types.QueryOpt, limit int) int {
if limit <= 0 {
return 0
}
if opts == nil || opts.Since <= 0 || opts.Before <= opts.Since {
return limit
}
expected := opts.Before - opts.Since
if expected <= 0 {
return limit
}
if expected > int64(limit) {
return limit
}
return int(expected)
}
func expandRanges(ranges []types.Range, limit int) []int64 {
if limit <= 0 {
return nil
@@ -488,6 +488,21 @@ func TestTopicAndSubscriptionCacheTTLIsShort(t *testing.T) {
}
}
func TestHotSeqExpectedCountUsesRangeSizeWhenSmallerThanLimit(t *testing.T) {
if got := hotSeqExpectedCount(&types.QueryOpt{Since: 41, Before: 54, Limit: 20}, 20); got != 13 {
t.Fatalf("expected range-sized count, got %d", got)
}
if got := hotSeqExpectedCount(&types.QueryOpt{Since: 41, Before: 80, Limit: 20}, 20); got != 20 {
t.Fatalf("expected limit-sized count, got %d", got)
}
if got := hotSeqExpectedCount(&types.QueryOpt{Since: 0, Before: 54, Limit: 20}, 20); got != 20 {
t.Fatalf("expected fallback limit count, got %d", got)
}
if got := hotSeqExpectedCount(nil, 20); got != 20 {
t.Fatalf("expected nil opts limit count, got %d", got)
}
}
func TestInvalidateSubscriptionCacheWithZeroUserDeletesTopicPrefix(t *testing.T) {
oldRuntime := groupMsgRuntime
runtime := newTestGroupMessageRuntime()