Skip to content

connector: don't save reconnection state before events are handled - #308

Open
Fizzadar wants to merge 1 commit into
mainfrom
nick/fix-meta-reconnect-state-checkpoint
Open

connector: don't save reconnection state before events are handled#308
Fizzadar wants to merge 1 commit into
mainfrom
nick/fix-meta-reconnect-state-checkpoint

Conversation

@Fizzadar

@Fizzadar Fizzadar commented Jul 27, 2026

Copy link
Copy Markdown
Member

The messagix sync cursor advances as soon as a table is parsed and queued, so persisting the dumped state while the derived events are still queued in memory. If the process restarts in this situation those events are lost forever.

The messagix sync cursor advances as soon as a table is parsed and queued,
so persisting the dumped state while the derived events are still queued
(or were dropped when the context was cancelled) checkpoints past work that
never happened. Meta then never re-reports those thread ranges, so any
messages in them are lost permanently.

Count outstanding parsed tables and skip saving the state while any are
unhandled. The counter is swapped for a fresh one when a new messagix client
is created, so a late decrement from the old table loop can't make the new
connection look up to date.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Fizzadar
Fizzadar requested a review from tulir July 27, 2026 14:17
@Fizzadar
Fizzadar marked this pull request as ready for review July 27, 2026 14:18
Comment thread pkg/connector/client.go
if pending := m.pendingTables.Load().Load(); pending != 0 {
zerolog.Ctx(ctx).Warn().
Int64("pending_tables", pending).
Msg("Not saving reconnection state, some events haven't been handled yet")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is safe as we'll just save it later?

@tulir

tulir commented Jul 31, 2026

Copy link
Copy Markdown
Member

Hmm, the saving should probably just be a part of the event stream like it is on instagram rather than a hacky atomic atomic integer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants