feat(federation): implement resetOutboxBackoff

Unconditionally resets nextRetryAt=now and attempts=0 for all
outbox entries of the given peer. No WHERE filter on nextRetryAt —
resetting attempts=0 on already-eligible rows is the correctness fix:
without it, a previously-failed entry keeps stale attempts, and its
next failure uses BACKOFF_SCHEDULE_MS[attempts] (5min to 24h) on a
peer that just recovered.
This commit is contained in:
Jannis Braun
2026-04-22 00:10:27 +02:00
parent 14a96efa58
commit fd37e0c604
2 changed files with 105 additions and 2 deletions
@@ -52,8 +52,16 @@ export async function onPeerActivated(
* Unconditional across all entries of the peer — see spec §Invariant 1.
*/
export function resetOutboxBackoff(peerId: string): void {
// Stub — implemented in Task 2.
void peerId;
const db = getDb();
const now = Date.now();
const result = db
.update(schema.federationOutbox)
.set({ nextRetryAt: now, attempts: 0 })
.where(eq(schema.federationOutbox.peerId, peerId))
.run();
if (result.changes > 0) {
console.log(`[federation] Reset backoff on ${result.changes} outbox entries for peer ${peerId}`);
}
}
/**