Repository navigation
backfill: fetch thread replies one at a time - #141
iFixRobots wants to merge 1 commit into
Conversation
|
1 potential issue found:
↑ Select any checkbox above to have Indent auto-fix the issue
All required CI checks passed on
Select any unchecked box below to run or rerun that agent. Full resultsIndent Review Agent
|
| if !ok { | ||
| return nil, fmt.Errorf("invalid thread root ID") | ||
| } | ||
| s.threadFetchLock.Lock() |
There was a problem hiding this comment.
🟡 Bug · Global thread lock stalls every portal's event loop, and waiters ignore ctx
bridgev2 runs thread backfill inside forward backfill, in the portal event loop (createMatrixRoomInLoop with roomCreateLock held, and handleChatResync). With this per-login lock, every portal's loop blocks until all threads queued ahead of it, in any channel, are fetched. The holder keeps the lock through slackgo's retry loop (OptionRetry(5)), which sleeps for each 429's Retry-After (60s default if missing), so one call can hold it for minutes and late channels can't process live messages, edits or reactions. sync.Mutex.Lock also ignores ctx, so a waiter whose context was cancelled (portal deleted, shutdown) keeps waiting and then makes a request anyway. Use a ctx-aware semaphore or a rate limiter (Wait(ctx)) instead.
Found by Indent Review Agent
A new login backfills every channel at once, and each one fetches its threads inline, so hundreds of
conversations.repliescalls hit Slack together. They all get rate limited, burn through the 5 retries at the same time, and the thread is dropped without its replies.Fetching thread replies one at a time per login lets the existing Retry-After handling actually work. I considered moving thread backfill out of the batch in bridgev2 (mautrix/go#665), but that's a lot more machinery for the same result.
Tag
@indentto continue the conversation here.