[PR #585] [MERGED] fix: run jobs at interval instead of specific time #714

Closed
opened 2025-10-07 00:21:06 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/pocket-id/pocket-id/pull/585
Author: @ItalyPaleAle
Created: 5/29/2025
Status: Merged
Merged: 5/29/2025
Merged by: @stonith404

Base: mainHead: background-job


📝 Commits (6)

  • 194a8e1 fix: run jobs at interval instead of specific time
  • e38fd91 Use a single transaction for all DB cleanup jobs
  • 126f9c2 Should have been 24 hours
  • 7c8c9a1 Log job start too
  • 4f94a6a Fix logging and errors
  • 12b15d5 Move back to multiple jobs, but with jitter

📊 Changes

7 files changed (+105 additions, -46 deletions)

View changed files

📝 backend/internal/job/analytics_job.go (+3 -1)
📝 backend/internal/job/api_key_expiry_job.go (+10 -6)
📝 backend/internal/job/db_cleanup_job.go (+55 -20)
📝 backend/internal/job/file_cleanup_job.go (+7 -4)
📝 backend/internal/job/geoloite_update_job.go (+5 -2)
📝 backend/internal/job/ldap_job.go (+4 -1)
📝 backend/internal/job/scheduler.go (+21 -12)

📄 Description

While this is helpful for all jobs, it's particularly useful for the analytics job, to avoid all instances to send the ping at the exact same time, and to make sure it's always about 24 hours away.

Additionally, runs all database cleanup jobs in a single transaction, to avoid contention when all cleanup jobs are started at the same time (since they'd be competing to lock the database, especially with SQLite).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/pocket-id/pocket-id/pull/585 **Author:** [@ItalyPaleAle](https://github.com/ItalyPaleAle) **Created:** 5/29/2025 **Status:** ✅ Merged **Merged:** 5/29/2025 **Merged by:** [@stonith404](https://github.com/stonith404) **Base:** `main` ← **Head:** `background-job` --- ### 📝 Commits (6) - [`194a8e1`](https://github.com/pocket-id/pocket-id/commit/194a8e1f8bcebbd460c9ed46c94460a9d7e16cee) fix: run jobs at interval instead of specific time - [`e38fd91`](https://github.com/pocket-id/pocket-id/commit/e38fd916944d033836adead0bfa02a5915b1376b) Use a single transaction for all DB cleanup jobs - [`126f9c2`](https://github.com/pocket-id/pocket-id/commit/126f9c251777b6c0f17af069deef85cfb32770e6) Should have been 24 hours - [`7c8c9a1`](https://github.com/pocket-id/pocket-id/commit/7c8c9a1c3f5d810d9c33c565292b2bd6667dd74b) Log job start too - [`4f94a6a`](https://github.com/pocket-id/pocket-id/commit/4f94a6a0ceafc0da68c45569e8aba065cfde6687) Fix logging and errors - [`12b15d5`](https://github.com/pocket-id/pocket-id/commit/12b15d5e78f66856711ec62935412b8a7d7e359c) Move back to multiple jobs, but with jitter ### 📊 Changes **7 files changed** (+105 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `backend/internal/job/analytics_job.go` (+3 -1) 📝 `backend/internal/job/api_key_expiry_job.go` (+10 -6) 📝 `backend/internal/job/db_cleanup_job.go` (+55 -20) 📝 `backend/internal/job/file_cleanup_job.go` (+7 -4) 📝 `backend/internal/job/geoloite_update_job.go` (+5 -2) 📝 `backend/internal/job/ldap_job.go` (+4 -1) 📝 `backend/internal/job/scheduler.go` (+21 -12) </details> ### 📄 Description While this is helpful for all jobs, it's particularly useful for the analytics job, to avoid all instances to send the ping at the exact same time, and to make sure it's always about 24 hours away. Additionally, runs all database cleanup jobs in a single transaction, to avoid contention when all cleanup jobs are started at the same time (since they'd be competing to lock the database, especially with SQLite). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-07 00:21:06 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id#714