Skip to content

fix: prevent first-owner write loss in in-memory stores - #1194

Merged
mykytanetipa merged 2 commits into
a2aproject:mainfrom
anxkhn:fix/inmemory-owner-dict-race
Aug 24, 2026
Merged

fix: prevent first-owner write loss in in-memory stores#1194
mykytanetipa merged 2 commits into
a2aproject:mainfrom
anxkhn:fix/inmemory-owner-dict-race

Conversation

@anxkhn

@anxkhn anxkhn commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

_InMemoryTaskStoreImpl.save and InMemoryPushNotificationConfigStore.set_info created owner buckets before acquiring their existing RLock. Two threads could both observe a missing owner, create separate buckets, and overwrite the bucket containing the first completed write.

This moves owner-bucket creation inside the lock with setdefault in both stores. Threaded regression tests cover concurrent first writes and confirm that both records remain available through the public retrieval methods.

Testing

uv run pytest tests/server/tasks/test_inmemory_task_store.py tests/server/tasks/test_inmemory_push_notifications.py -q

Result: 40 passed.

@anxkhn
anxkhn requested a review from a team as a code owner August 20, 2026 16:39
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
@anxkhn
anxkhn force-pushed the fix/inmemory-owner-dict-race branch from a09e2ad to 1e833b7 Compare August 20, 2026 20:48
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/tasks/inmemory_task_store.py 97.14% 97.06% 🔴 -0.08%
Total 93.00% 92.99% 🔴 -0.01%

Generated by coverage-comment.yml

@mykytanetipa mykytanetipa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@mykytanetipa
mykytanetipa merged commit bcc489c into a2aproject:main Aug 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants