fix: lucky_gift_outbox delivered 保留期收紧为 7 天

线上实测 delivered 约 9 万行/天且该表无下游读方(事实在 lucky_draw_records),
30 天窗口会让表膨胀到近 300 万行;7 天足够排障。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
zhx 2026-07-10 16:42:30 +08:00
parent 79e60f3815
commit 551ad9b03a
3 changed files with 7 additions and 5 deletions

View File

@ -74,8 +74,9 @@ func Default() Config {
StatsRefreshInterval: 10 * time.Minute,
StatsBatchSize: 5000,
Retention: OutboxRetentionConfig{
Enabled: true,
MaxAge: 30 * 24 * time.Hour,
Enabled: true,
// 线上 delivered 约 9 万行/天且无下游读方7 天足够排障30 天会让表膨胀到近 300 万行。
MaxAge: 7 * 24 * time.Hour,
ScanInterval: 5 * time.Minute,
BatchSize: 500,
},

View File

@ -17,8 +17,8 @@ func TestLoadDefaultsEnableOutboxRetention(t *testing.T) {
if !retention.Enabled {
t.Fatal("retention should be enabled by default")
}
if retention.MaxAge != 30*24*time.Hour {
t.Fatalf("retention.MaxAge = %s, want 720h", retention.MaxAge)
if retention.MaxAge != 7*24*time.Hour {
t.Fatalf("retention.MaxAge = %s, want 168h", retention.MaxAge)
}
if retention.ScanInterval != 5*time.Minute {
t.Fatalf("retention.ScanInterval = %s, want 5m", retention.ScanInterval)

View File

@ -23,9 +23,10 @@ type OutboxRetentionOptions struct {
func defaultOutboxRetentionOptions() OutboxRetentionOptions {
// 默认值和 config.Default 的 retention 保持一致,防止手动构造绕过配置归一化后误删新事件。
// 线上 delivered 约 9 万行/天且无下游读方7 天窗口在可排障和表体积之间取平衡。
return OutboxRetentionOptions{
ScanInterval: 5 * time.Minute,
MaxAge: 30 * 24 * time.Hour,
MaxAge: 7 * 24 * time.Hour,
BatchSize: 500,
}
}