Node.js Scheduled Data Cleanup: Cron-Gated Deletion of Old PostgreSQL Digest Records
Short answer: schedule one durable cleanup run, feed bounded PostgreSQL delete batches through a queue, and admit each batch only while the weekly fintech digest remains inside its latency budget. The worker must be idempotent because both the cron trigger and queue delivery can repeat; the database, not the scheduler or broker, should decide whether an old log row is still eligible. This design deliberately optimizes for foreground latency before cleanup speed. Retention work can finish later.…