-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For PrimaryReadReplicaConnection passthrough primary server version #5981
Conversation
Passthrough server version from primary.
Thank you. Please provide a test that reproduces the problem you're attempting to fix. |
@derrabus okay I have added a test. I couldn't see any previous tests where we check the serverVersion parsed from the connection config. So hopefully I have done something which is acceptable. |
Thank you for the test. However, I don't see how this reproduces the issue you're having. As far as I can tell, the test makes some assertions on the array returned by |
@derrabus okay thank you for the feedback. As I said initially I don't really know the DBAL codebase, so I'm not sure if I have fixed the issue in the correct place. Let me try and explain the issue I'm experiencing and maybe you can point me to the best place to fix it in. Following the Symfony guidelines on setting up a database connection I have this:
Although you say this is now deprecated, so maybe that is why I'm getting the issue. Anyway after this url is parsed into all the individual parameters. For the
Now eventually this gets used by So this test was to validate that the |
The other option is I can update |
I didn't say that.
I doubt it. 🙂
And with that piece of configuration, do you still encounter the issue? If yes, let's leave URLs out of this test as they just add unnecessary complexity.
I get that, but whether or not |
@derrabus Okay well I have reworked the fix and tests. Hopefully this is to your satisfaction now. I also included a test to cover non-replica connections as there didn't seem to be coverage for this. |
Anything else I need to do to this? |
Looks good, thank you! |
Passthrough server version from primary.
Summary
When running
cache:clear
in Symfony we started to get an issue where it was trying to connect to the database after introducing replicas (like: symfony/symfony#37473.)In
src/Connection.php
getDatabasePlatformVersion()
it is expecting theserverVersion
parameter. However for thePrimaryReadReplicaConnection
this is one level up in the primary connection.I don't know the best place for this, so I have put it in the constructor for
PrimaryReadReplicaConnection
that it copies anyserverVersion
from the primary to the root forConnection
to use.If anyone who knows this code better thinks this should live somewhere else I'm happy to update my PR.