[5.3] Defer resolving read PDO of read/write connection until needed #15031
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.
This PR updates the read/write connection so that resolving the PDO instance for the read connection is also deferred until it is needed.
When using a single connection for both reads and writes, the PDO instance is not resolved until the connection is actually needed.
When using separate read/write connections, the PDO instance for the write connection is not resolved until needed, but the PDO instance for the read connection is resolved immediately.
This leads to a minor inconsistency of how reading from a single connection works when compared to how reading from a read/write connection works. If one switches from using a single connection to using a read/write connection, one may incur an unexpected increase in connections to the read database.
It is also slightly inconsistent when comparing how the read connection works to how the corresponding write connection works. One may expect that if the write connection is going to be deferred, then the read connection should be deferred, as well.
I could not find a stated reason for this difference, so I thought it may be something open for change. If there is a reason for this difference, I would love to learn, and I apologize for the wasted PR. Additionally, please let me know if anything should be changed, or if this should be targeted at 5.2.