feat(tables): add automatic row expiration with TTL - #7071
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds a TTL table-column type backed by Unix epoch seconds, including validation, timezone-aware editing, import and conversion support, and documentation.
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking cleanup-fairness issue that can leave later tables behind under sustained high-volume expiration workloads. The TTL representation and mutation paths are internally consistent, but the cleanup worker's fixed ordering and shared batch budget allow an early table to repeatedly monopolize scheduled cleanup capacity. Files Needing Attention: apps/sim/background/cleanup-table-row-ttl.ts
|
| Filename | Overview |
|---|---|
| apps/sim/background/cleanup-table-row-ttl.ts | Implements locked, batched TTL deletion; the global budget and fixed table ordering can create unbounded lag under sustained backlog. |
| apps/sim/lib/table/column-types/ttl.ts | Defines TTL epoch-second coercion, validation, conversion, and timezone-aware formatting. |
| apps/sim/lib/table/columns/service.ts | Applies source-aware value conversion and validates the resulting schema before retyping columns. |
| apps/sim/lib/table/schema-invariants.ts | Extends shared schema invariants with registry-declared per-table column limits. |
| apps/sim/app/api/cron/cleanup-table-row-ttl/route.ts | Adds an authenticated cron endpoint that dispatches one deduplicated, serialized cleanup job. |
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/inline-editors.tsx | Normalizes date-editor saves through timezone-aware column coercion so TTL cells persist epoch seconds. |
| helm/sim/values.yaml | Enables the TTL cleanup endpoint on a five-minute non-overlapping cron schedule. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Cron[Five-minute cron] --> Route[Authenticated cleanup route]
Route --> Queue[Serialized cleanup job]
Queue --> List[List tables with expired TTL rows]
List --> Lock[Acquire table advisory lock]
Lock --> Batch[Delete up to 500 expired rows]
Batch -->|More rows and budget remains| Lock
Batch -->|Table complete| Signal[Signal table rows changed]
Signal -->|More tables and budget remains| Lock
Reviews (1): Last reviewed commit: "feat(tables): add row TTL expiration" | Re-trigger Greptile
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Summary
Tables can now expire rows automatically with one TTL column. Expiration values are stored as Unix epoch seconds, edited with the existing date UI, and removed by a bounded background cleanup job that notifies realtime clients.
This is the first PR in a two-PR stack. PR #7072 consolidates and hardens the timezone conversion used by TTL and date cells.
Type of Change
Testing
Checklist
Screenshots/Videos
No recording is included. Component tests cover the TTL selector, disabled one-column state, and cell rendering.
Post-Deploy Monitoring & Validation
Table row TTL cleanup dispatched,Table row TTL cleanup completed, andFailed to dispatch table row TTL cleanup.cleanup-table-row-ttl.limitReachedis normally false; seeded expired rows disappear and future rows remain.limitReached: true, or any row deleted before its stored epoch second.