Skip to content

feat(jobs): prune venue_dispersions, quarantined_price_points and oracle_publications - #811

Open
AGWAM001 wants to merge 1 commit into
Divinity-Labs:mainfrom
AGWAM001:fix/audit-table-pruning
Open

AGWAM001 wants to merge 1 commit into
Divinity-Labs:mainfrom
AGWAM001:fix/audit-table-pruning

Conversation

@AGWAM001

Copy link
Copy Markdown
Contributor

Summary

The three audit tables — venue_dispersions, quarantined_price_points and oracle_publications — were written forever and never pruned. This adds a retention job modelled on snapshotRetention.ts:

  • New src/jobs/auditRetention.ts: batched per-network deletes per table on its own time column (timestamp / quarantined_at / created_at), using ctid + FOR UPDATE SKIP LOCKED with a yield between batches; table/column names are hard-coded constants, all values are bound parameters
  • One env retention setting per table, with defaults checked against the readers: VENUE_DISPERSION_RETENTION_DAYS=30, QUARANTINED_PRICE_POINT_RETENTION_DAYS=30, ORACLE_PUBLICATION_RETENTION_DAYS=90, shared AUDIT_PRUNE_BATCH_SIZE=1000 — all documented in .env.example
  • One table's failure does not stop the others: every table/network is attempted, failures are aggregated
  • Started from src/index.ts at boot plus an hourly BullMQ schedule, with the same in-process timer fallback on Redis failure as the other retention jobs
  • No new indexes added; note that a plain (network, <time>) index may help a first prune on a very large table

Tests

  • New src/__tests__/auditRetention.test.ts: 12/12 pass (SQL/time column/params per table, defaults, nothing-to-delete, batched drain, invalid batch size, multi-network, one-table-fails-others-continue)
  • Neighbouring suites pass: snapshotRetention 9/9, envDrift 4/4
  • Full suite failures locally are pre-existing/environmental (ungenerated Prisma client in the sandbox), verified identical on clean main

Closes #690

@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@AGWAM001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Three audit tables are written forever and never pruned

1 participant