Skip to content

Commit 340b4d2

Browse files
committed
chore(tables): run TTL cleanup every fifteen minutes
1 parent 33b91aa commit 340b4d2

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

apps/sim/app/api/cron/cleanup-table-row-ttl/route.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('table row TTL cleanup route', () => {
1919
beforeEach(() => {
2020
vi.clearAllMocks()
2121
vi.useFakeTimers()
22-
vi.setSystemTime(new Date('2026-08-22T17:12:00Z'))
22+
vi.setSystemTime(new Date('2026-08-22T17:01:00Z'))
2323
mockVerifyCronAuth.mockReturnValue(null)
2424
mockEnqueue.mockResolvedValue('job-ttl-1')
2525
mockGetJobQueue.mockResolvedValue({ enqueue: mockEnqueue })
@@ -46,15 +46,15 @@ describe('table row TTL cleanup route', () => {
4646
{},
4747
expect.objectContaining({
4848
maxAttempts: 1,
49-
jobId: 'cleanup-table-row-ttl:5958062',
49+
jobId: 'cleanup-table-row-ttl:1986020',
5050
concurrencyKey: 'cleanup:table-row-ttl',
5151
concurrencyLimit: 1,
5252
runner: expect.any(Function),
5353
})
5454
)
5555
})
5656

57-
it('deduplicates retries within the same five-minute schedule window', async () => {
57+
it('deduplicates retries within the same fifteen-minute schedule window', async () => {
5858
const request = () =>
5959
createMockRequest(
6060
'GET',
@@ -64,7 +64,7 @@ describe('table row TTL cleanup route', () => {
6464
)
6565

6666
await GET(request())
67-
vi.advanceTimersByTime(2 * 60 * 1000)
67+
vi.advanceTimersByTime(13 * 60 * 1000)
6868
await GET(request())
6969

7070
expect(mockEnqueue.mock.calls[0]?.[2]?.jobId).toBe(mockEnqueue.mock.calls[1]?.[2]?.jobId)

apps/sim/app/api/cron/cleanup-table-row-ttl/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
77
export const dynamic = 'force-dynamic'
88

99
const logger = createLogger('CleanupTableRowTtlApi')
10-
const TTL_CLEANUP_INTERVAL_MS = 5 * 60 * 1000
10+
const TTL_CLEANUP_INTERVAL_MS = 15 * 60 * 1000
1111

1212
export const GET = withRouteHandler(async (request: NextRequest) => {
1313
try {

docker/crontab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ SHELL=/bin/sh
4040
0 * * * * curl -fsS -m 300 -o /dev/null -H "Authorization: Bearer $CRON_SECRET" "$SIM_URL/api/cron/run-data-drains"
4141

4242
# Deletes table rows whose TTL column has expired
43-
*/5 * * * * curl -fsS -m 60 -o /dev/null -H "Authorization: Bearer $CRON_SECRET" "$SIM_URL/api/cron/cleanup-table-row-ttl"
43+
*/15 * * * * curl -fsS -m 60 -o /dev/null -H "Authorization: Bearer $CRON_SECRET" "$SIM_URL/api/cron/cleanup-table-row-ttl"
4444

4545
# Microsoft Graph subscription renewal (Teams chat triggers expire after ~3 days)
4646
0 */12 * * * curl -fsS -m 120 -o /dev/null -H "Authorization: Bearer $CRON_SECRET" "$SIM_URL/api/cron/renew-subscriptions"

helm/sim/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ cronjobs:
14581458
cleanupTableRowTtl:
14591459
enabled: true
14601460
name: cleanup-table-row-ttl
1461-
schedule: "*/5 * * * *"
1461+
schedule: "*/15 * * * *"
14621462
path: "/api/cron/cleanup-table-row-ttl"
14631463
concurrencyPolicy: Forbid
14641464
successfulJobsHistoryLimit: 3

0 commit comments

Comments
 (0)