Skip to content

fix(session): make InMemorySessionStore.messageID atomic (#3592)#3607

Merged
dgageot merged 1 commit into
mainfrom
fix/3592-atomic-messageid
Jul 13, 2026
Merged

fix(session): make InMemorySessionStore.messageID atomic (#3592)#3607
dgageot merged 1 commit into
mainfrom
fix/3592-atomic-messageid

Conversation

@aheritier

@aheritier aheritier commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #3592InMemorySessionStore.messageID was a plain int64 incremented
without synchronization while the store is accessed concurrently (HTTP handlers

  • the runtime PersistenceObserver). Lost increments could produce duplicate
    message IDs, which in turn let UpdateMessage (which searches by ID) edit the
    wrong message.

What changed

  • messageID is now atomic.Int64, incremented via Add(1). ID semantics are
    preserved: the counter starts at zero and Add(1) yields 1, 2, …, matching
    the previous pre-increment behavior.

Testing

  • pkg/session/store_messageid_race_test.go — 200 concurrent AddMessage
    calls assert all returned IDs are unique. Verified to fail (duplicate IDs +
    data-race warnings, all iterations) against the pre-fix plain-int64 code and
    pass now.
  • task dev + go test -race -count=2 ./pkg/session/...: green (validated in
    isolation).

@aheritier aheritier added kind/fix PR fixes a bug (maps to fix:). Use on PRs only. area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) labels Jul 11, 2026
@aheritier aheritier self-assigned this Jul 13, 2026
@aheritier aheritier marked this pull request as ready for review July 13, 2026 08:11
@aheritier aheritier requested a review from a team as a code owner July 13, 2026 08:11
@dgageot dgageot merged commit baa8763 into main Jul 13, 2026
16 checks passed
@dgageot dgageot deleted the fix/3592-atomic-messageid branch July 13, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(session): make InMemorySessionStore.messageID increment atomic

2 participants