Purge dynamic database connection before setting a new one - #5682
Open
Linux123123 wants to merge 1 commit into
Open
Purge dynamic database connection before setting a new one#5682Linux123123 wants to merge 1 commit into
Linux123123 wants to merge 1 commit into
Conversation
… cached connection is not used
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.
DynamicDatabaseConnectioncurrently sets the database host credentials inConfigRepository, which is not used if a connection with that name is already cached inDatabaseManager. See the code here:https://github.com/laravel/framework/blob/ee0296f03a02b8f890c6323f18bdf4669468c0c2/src/Illuminate/Database/DatabaseManager.php#L94-L110
This issue shows up wherever it is necessary to connect to multiple database hosts one after another (for example,
ServerDeletionService).In the aforementioned
ServerDeletionService, this means some databases are not deleted, and there is no error. Unwanted deletions are unlikely to happen becauseDROP DATABASE IF EXISTSis used, along with databases being prefixed with server ID, they will not exist on any other database hosts.I would really suggest everyone go over the database hosts and check if there are any undeleted databases. We found around 4,000 databases that were not in the panel database table. Basically, if the server had databases from multiple hosts, only the databases from the first host would be deleted.
Credits to @barrelltitor for finding the issue.