Skip to content

fix: tolerate concurrent guild creation - #121

Open
vycdev2 wants to merge 1 commit into
vycdev:developfrom
vycdev2:fix/concurrent-guild-creation-20260809
Open

fix: tolerate concurrent guild creation#121
vycdev2 wants to merge 1 commit into
vycdev:developfrom
vycdev2:fix/concurrent-guild-creation-20260809

Conversation

@vycdev2

@vycdev2 vycdev2 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Recover when concurrent handlers race to create the same Discord guild.
  • Clear the failed EF insert and reload the row protected by the unique DiscordId index.
  • Preserve the persisted prefix in the in-memory prefix cache.
  • Add a SQLite regression test that reproduces the losing-insert path.

Verification

  • dotnet restore Morpheus.sln --nologo - passed (existing SQLite package advisory warning).
  • dotnet build Morpheus.sln --no-restore --nologo - passed with 0 errors.
  • Focused GuildServiceConcurrencyTests - passed, 1/1.
  • Full dotnet test - 298 passed and the two pre-existing tr-TR globalization-invariant cases failed.
  • Full suite excluding NormalizeTimeUntilEventName_NormalizesCase - passed, 298/298.
  • Targeted dotnet format ... --verify-no-changes for both changed files - passed.
  • git diff --check upstream/develop...HEAD - passed.

Risk

Low. Recovery runs only after a failed guild insert and rethrows if no matching persisted guild exists.

This was generated by an AI agent (vycdev2). Please verify any changes before merging or applying.

@vycdev2
vycdev2 changed the base branch from main to develop August 9, 2026 23:21
@vycdev2
vycdev2 force-pushed the fix/concurrent-guild-creation-20260809 branch from a8bd20a to 33875de Compare August 9, 2026 23:21

vycdev commented Aug 10, 2026

Copy link
Copy Markdown
Owner

This needs a small integration fix before merging:

  • The PR conflicts with the guild-name refresh logic now on develop; please preserve that existing behavior while resolving the conflict.
  • In the concurrent-insert recovery path, the winning row can contain a stale guild name. Update concurrentGuild.Name to the current name and persist it before returning, matching the normal existing-row path and the recently merged channel-race handling.
  • Update the regression test to expect "current-name", and verify that GuildPrefixService.GetPrefixAsync(123) returns the persisted prefix after recovery. The current test claims prefix-cache coverage but does not assert it.

The intended race recovery itself looks appropriate; these changes should make it consistent with current develop.

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