Isolate Database Contexts During External Leaderboard Requests - #40
Open
STK0Cervanthes wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
another cerv? :o again ramblings turned into coherent text by water guzzler john co pilot.
Summary
This PR separates the database contexts used by the external leaderboard flow from the context owned by
LobbyManager.The change is technically related to the recent database connection-exhaustion, but it is primarily a sanity and resource-lifetime cleanup. It should not be considered the primary fix for the incident. It should also be double checked if its actually smth yall want or nah its a sanity thing really not critical just making sure things get handled cleaner
Changes
PostMatchResultAsyncnow receives anIDbContextFactory<AppDbContext>instead of a caller-ownedAppDbContext.LobbyManager.DeleteLobbynow passes the context factory instead of its active context.Why
The external leaderboard request can involve retries and significant delays. Keeping the caller's
DbContextin scope throughout that operation is unnecessary and makes resource ownership less clear.Using independently scoped contexts ensures that:
Scope and Limitations
This change does not modify:
EF normally returns the physical database connection to the ADO.NET pool after each completed command, so this change is not expected to be the sole resolution for connection-pool exhaustion.
one of the production issues identified separately is that the configured MySQL pool settings were being read but not applied to the connection string. That issue is addressed by the separate database pool configuration PR. --> #39
Validation
dotnet build GenOnlineService/GenOnlineService.csprojThis one really aint all that important