mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
[doc-updater] fix unbounded Redis key growth in project notifications cron (#35425)
* delete timestamp notification keys for solo projects * add fallback 7d TTL for keys GitOrigin-RevId: e0493e74b14b861863afc1d4ef5fa181432ad450
This commit is contained in:
@@ -16,6 +16,7 @@ const rclient = RedisWrapper.createClient(Settings.redis.documentupdater)
|
||||
// hold us up, and need to bail out quickly if there is a problem.
|
||||
const MAX_REDIS_REQUEST_LENGTH = 5000 // 5 seconds
|
||||
const PROJECT_BLOCK_TTL_SECS = 30
|
||||
const ONE_DAY_SECS = 24 * 60 * 60
|
||||
|
||||
// Make times easy to read
|
||||
const minutes = 60 // seconds for Redis expire
|
||||
@@ -575,6 +576,8 @@ const RedisManager = {
|
||||
await rclient.set(
|
||||
keys.projectNotificationTimestamp({ project_id: projectId }),
|
||||
timestamp,
|
||||
'EX',
|
||||
7 * ONE_DAY_SECS,
|
||||
'NX'
|
||||
)
|
||||
},
|
||||
|
||||
@@ -384,6 +384,9 @@ async function getProjectsToNotify(): Promise<{
|
||||
for (const c of candidates) {
|
||||
if (!projectsWithCollaborators.has(c.projectId)) {
|
||||
stats.skippedNoCollaborators++
|
||||
if (!dryRun) {
|
||||
await deleteProjectNotificationTimestamp(c.projectId, c.timestamp)
|
||||
}
|
||||
continue
|
||||
}
|
||||
stats.matched++
|
||||
|
||||
Reference in New Issue
Block a user