diff --git a/CHANGELOG.md b/CHANGELOG.md index 88dc308f0e526b16f05477500b70e4d5bade121a..47372dda568dd9804973362b1b85e36688b763fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Improvements - ä¾å˜é–¢ä¿‚ã®æ›´æ–° - localStorageã®accountsã¯indexedDBã§ä¿æŒã™ã‚‹ã‚ˆã†ã« +- ActivityPub: ジョブã‚ューã®è©¦è¡Œã‚¿ã‚¤ãƒŸãƒ³ã‚°ã‚’調整 (#7635) ### Bugfixes - ãƒãƒ£ãƒ³ãƒãƒ«ã‚’作æˆã—ã¦ã„ã‚‹ã¨ã‚¢ã‚«ã‚¦ãƒ³ãƒˆã‚’削除ã§ããªã„ã®ã‚’ä¿®æ£ diff --git a/src/queue/index.ts b/src/queue/index.ts index 2facd9c8e19105f695b4fe5277159044f3d52a59..ff96c0fb15e18cb9933ba82056e980eeca148880 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -73,8 +73,7 @@ export function deliver(user: ThinUser, content: unknown, to: string | null) { attempts: config.deliverJobMaxAttempts || 12, timeout: 1 * 60 * 1000, // 1min backoff: { - type: 'exponential', - delay: 60 * 1000 + type: 'apBackoff' }, removeOnComplete: true, removeOnFail: true @@ -91,8 +90,7 @@ export function inbox(activity: IActivity, signature: httpSignature.IParsedSigna attempts: config.inboxJobMaxAttempts || 8, timeout: 5 * 60 * 1000, // 5min backoff: { - type: 'exponential', - delay: 60 * 1000 + type: 'apBackoff' }, removeOnComplete: true, removeOnFail: true diff --git a/src/queue/initialize.ts b/src/queue/initialize.ts index 5fe5a9f6f337c62a831675aad915170da2a8ea51..31102a3ed2dfb206b8c446f41c40055263c259b3 100644 --- a/src/queue/initialize.ts +++ b/src/queue/initialize.ts @@ -11,8 +11,23 @@ export function initialize<T>(name: string, limitPerSec = -1) { }, prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : 'queue', limiter: limitPerSec > 0 ? { - max: limitPerSec * 5, - duration: 5000 - } : undefined + max: limitPerSec, + duration: 1000 + } : undefined, + settings: { + backoffStrategies: { + apBackoff + } + } }); } + +// ref. https://github.com/misskey-dev/misskey/pull/7635#issue-971097019 +function apBackoff(attemptsMade: number, err: Error) { + const baseDelay = 60 * 1000; // 1min + const maxBackoff = 8 * 60 * 60 * 1000; // 8hours + let backoff = (Math.pow(2, attemptsMade) - 1) * baseDelay; + backoff = Math.min(backoff, maxBackoff); + backoff += Math.round(backoff * Math.random() * 0.2); + return backoff; +}