fix(sync): wire dead token cleanup queries into daily maintenance runner
CleanupExpiredRefreshTokens and CleanupExpiredOpdsTokens were generated by sqlc but never invoked anywhere in the codebase, so expired/revoked tokens accumulated in the database indefinitely. The refresh-token query was parameterized in the settings-registry work specifically so its retention window could follow the configurable session duration, but the periodic caller was never wired up. annotations.go: - Rename StartTombstonePurger to StartDailyMaintenance, which now runs all periodic cleanup tasks from a single 24h-tick goroutine. - Add runDailyMaintenance helper: tombstones, then OPDS tokens, then refresh tokens, each logging independently so one failure never skips the others. - Refresh-token retention is read from the registry (SessionDuration) on every tick so live admin edits are honored; guarded on the registry being wired so unwired test paths simply skip cleanup. - All three queries only delete rows that are already expired or revoked, so active sessions are never logged out. main.go: - Update the call site: tombstonePurgerCancel becomes maintenanceCancel and calls StartDailyMaintenance. Net footprint: still one goroutine and one ticker; the cleanup adds one DELETE per table per day.
This commit is contained in:
+2
-2
@@ -111,8 +111,8 @@ func main() {
|
||||
progressService := sync.NewProgressService(queries, connManager)
|
||||
annotationService := sync.NewAnnotationService(queries, connManager)
|
||||
annotationService.SetSettings(registry)
|
||||
tombstonePurgerCancel := annotationService.StartTombstonePurger()
|
||||
defer tombstonePurgerCancel()
|
||||
maintenanceCancel := annotationService.StartDailyMaintenance()
|
||||
defer maintenanceCancel()
|
||||
|
||||
queueProcessor := sync.NewSyncQueueProcessorWithConfig(queries, registry.SyncQueueConfig().Interval, registry.SyncQueueConfig().BatchSize)
|
||||
queueProcessor.SetProgressService(progressService)
|
||||
|
||||
Reference in New Issue
Block a user