Skip to main content
← Back to list
01Issue
BugOpenSwamp ClubPublic
AssigneesNone

Relationships

#5146 Attio sync and sweep work runs on the request Mongo lane, not the background lane

Opened by swamp_lord · 11/26/2026

Problem

Background loops are meant to take the "background" lane (lib/db.ts, lib/app/repos.ts) so that a sweep can never hold a request's connection. Attio follows that rule only for its queue claim: main.ts passes getAttioSyncQueue("background").

The work done for each entry runs on the request pool:

  • getAttioSyncDeps, getAttioPersonCoverageDeps, getAttioPersonSweepDeps and getAttioStageSweepDeps (lib/app/repos.ts) open AttioSyncState on getDatabase().
  • Every nested repo they pull in is a request-lane singleton with no lane option: getCollectiveQueryService, getOperativeRepo, getSubscriptionRepo, getSsoQueryService, getCollectiveRepo, getOperativeCrmReaders and getMigrationRepo.
  • The sweeps also call getAttioSyncQueue() with its default request lane.
  • main.ts wires most other loops the same way (trial-ended, returning-trial, nurture, scoring): only the queue is on the background lane.

Split out of swamp-club#5091. The 2026-11-24 pool timeouts there turned out to come from a blocked event loop, not this, so this is the lane-rule violation on its own.

Suggested fix

  • Give the nested getters a lane parameter, the way getAttioSyncQueue(lane) and getServeLinkRepo(lane) already work.
  • Wire the Attio deps with "background".
  • Decide whether the 10-connection background pool can carry Attio's burst volume (about 20k queue.attio-sync.* spans per 5 minutes at peak) without starving the other loops' claims. It may need its own lane or a bigger pool, sized against the Atlas per-node limit.
  • Consider a fitness test asserting that nothing startBackgroundServices wires reaches getDatabase().
02Bog Flow
◉OPEN○TRIAGED○IN PROGRESS○SHIPPEDTRIAGE

Open

11/26/2026, 8:48:36 PM

Click a lifecycle step above to view its details.

03Sludge Pulse

Sign in to post a ripple.