feat(v1.1.1-gc): dead-letter + abandoned-executions retention sweepers
Two tokio tasks spawned at startup that sweep their respective tables on a weekly cadence (design notes §3 #9 + §4 retention). Both use `FOR UPDATE SKIP LOCKED` on the claim query so concurrent sweepers in cluster mode (v1.3+) don't fight each other. Defaults: 30 days for dead_letters, 7 days for abandoned_executions. Both env-overridable via `PICLOUD_DEAD_LETTER_RETENTION_DAYS` and `PICLOUD_ABANDONED_EXECUTIONS_RETENTION_DAYS` (loaded into `TriggerConfig::from_env` from commit 5). Per-tick batch cap (5_000 rows) so a sweep can't lock up the table in a single transaction; the inner loop continues until 0 rows affected, after which the outer tick waits for the next week. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -220,8 +220,16 @@ pub async fn build_app(pool: PgPool, auth: AuthDeps) -> anyhow::Result<Router> {
|
||||
inbox: inbox_registry,
|
||||
outbox: outbox_writer,
|
||||
};
|
||||
// Commit 10 wires abandoned_repo into the GC sweeper.
|
||||
let _ = &abandoned_repo;
|
||||
// Weekly retention sweepers for dead_letters + abandoned_executions.
|
||||
// Defaults: 30 days / 7 days (design notes §3 #9 + §4 retention).
|
||||
picloud_manager_core::spawn_dead_letter_gc(
|
||||
dl_repo.clone(),
|
||||
trigger_config.dead_letter_retention_days,
|
||||
);
|
||||
picloud_manager_core::spawn_abandoned_gc(
|
||||
abandoned_repo.clone(),
|
||||
trigger_config.abandoned_retention_days,
|
||||
);
|
||||
let triggers_state = TriggersState {
|
||||
triggers: trigger_repo,
|
||||
apps: apps_repo.clone(),
|
||||
|
||||
Reference in New Issue
Block a user