• Elysia's avatar
    fix: fix outbox watermark context expiry and add in-batch group rebuild dedup · 560cdad7
    Elysia authored and 陈曦's avatar 陈曦 committed
    
    
    Fixes #1691
    
    - pollOutbox() reused a 10s context for SetOutboxWatermark after event
      processing could take much longer, causing "outbox watermark write
      failed: context deadline exceeded". The watermark never advanced so
      the same 200 events were reprocessed every poll cycle, spiking CPU.
      Now uses an independent 5s context with up to 3 retries (200ms apart).
    
    - When multiple Codex accounts sharing the same 21-22 groups are all
      rate-limited in quick succession, each account_changed event triggered
      redundant bucket rebuild attempts for the same groups. Introduce
      batchSeenKey{groupID, platform} and thread a seen map through the
      handler chain; rebuildBucketsForPlatform skips (group, platform) pairs
      already rebuilt within the same poll batch (~80% fewer rebuild calls in
      the 5-accounts-same-groups scenario).
    Co-Authored-By: default avatarClaude Sonnet 4.6 (1M context) <noreply@anthropic.com>
    560cdad7
scheduler_snapshot_service.go 24.6 KB