Skip to content

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

Open
anxkhn wants to merge 1 commit into
a2aproject:mainfrom
anxkhn:fix/inmemory-owner-dict-race
Open

fix: prevent first-owner write loss in in-memory stores#1194
anxkhn wants to merge 1 commit into
a2aproject:mainfrom
anxkhn:fix/inmemory-owner-dict-race

Conversation

@anxkhn

@anxkhn anxkhn commented Aug 20, 2026

Copy link
Copy Markdown

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

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 92.97% 92.97% 🔴 -0.01%

Generated by coverage-comment.yml

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.

1 participant