Skip to content

fix(groups): use atomic operation for memberCount on member removal#15607

Open
edvinasetherel wants to merge 1 commit intoHabitRPG:developfrom
edvinasetherel:fix/group-remove-member-membercount
Open

fix(groups): use atomic operation for memberCount on member removal#15607
edvinasetherel wants to merge 1 commit intoHabitRPG:developfrom
edvinasetherel:fix/group-remove-member-membercount

Conversation

@edvinasetherel
Copy link
Copy Markdown

Related to #12286

Changes

  • Fixed a race condition in removeGroupMember where memberCount could become inconsistent under concurrent removals
  • Replaced read-modify-write logic with an atomic $inc update for memberCount field
  • Refactored control flow for clarity
  • Added integration test verifying consistent member count under concurrent removals

Notes

This PR addresses removeGroupMember only. Other group endpoints that modify
memberCount are intentionally out of scope to keep the change minimal
and easy to review

UUID:
ddbb1bd4-bb04-4798-8d69-02e77ad7ff71

  Replace read-modify-write pattern with MongoDB's $inc operator to prevent
  race conditions when multiple members are removed concurrently. Refactored
  removeGroupMember controller with helper functions and added integration
  tests to verify consistent member counts under concurrent operations
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