-
This is a followup to #1073. When connecting to a database, a
I would like to setup a retry policy in the case where the database server is under pressure but just error when the server and/or port is misconfigured. Is there a way to do that in MySqlConnector? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
I would expect to see If they're both reporting |
Beta Was this translation helpful? Give feedback.
-
Can you give full exception call stacks for the three cases?
Is that a first-chance exception, or the final unhandled exception? |
Beta Was this translation helpful? Give feedback.
-
Hi @bgrainger. Below are the stack traces for each of the above scenarios. Scenario 1
Scenario 2
Scenario 3
|
Beta Was this translation helpful? Give feedback.
-
The following call stack will happen any time the client can open a connection to the server, but the server returns an error packet:
If that doesn't happen, then the most likely cause is that a connection to the server couldn't actually be established. I don't see evidence of a bug/race condition yet. Are you claiming that you get different (but completely consistent and reproducible) exceptions depending on whether you run the program under the debugger or from the console? (And it's the same Debug or Release build in both cases?) |
Beta Was this translation helpful? Give feedback.
-
When the connection couldn't be established, could a different error be returned so the client can distinguish between this case and the case where the server/port is misconfigured? E.g. |
Beta Was this translation helpful? Give feedback.
-
In general, no: that would be a breaking change for any code currently examining the current errors.
I don't yet understand how those two scenarios are different; can you elaborate? "establishing a connection" is performing the TCP 3-way handshake (https://developer.mozilla.org/en-US/docs/Glossary/TCP_handshake) followed by reading the "server hello" packet the server sends, and responding with a (hashed) password. If there are too many connections, the server will send an error packet instead of the hello packet. If the TCP connection can't be established, If you think you're observing something different, you could collect a packet capture (with Wireshark, tcpdump, etc.) and show how MySqlConnector isn't returning the right response. If your use case for your application is that server/port might commonly be incorrect (is this user-entered data that needs to be verified?) you might need to take more control by opening a |
Beta Was this translation helpful? Give feedback.
-
@bgrainger was unable to reproduce the error on his environment, which inspired me to repeat my checks in a sanitized environment. Sure enough the issue isn't present there so we can conclude that the issue described above is unique to my machine (either a resourcing issue or contention with security software). Thanks for all your help @bgrainger! |
Beta Was this translation helpful? Give feedback.
@bgrainger was unable to reproduce the error on his environment, which inspired me to repeat my checks in a sanitized environment. Sure enough the issue isn't present there so we can conclude that the issue described above is unique to my machine (either a resourcing issue or contention with security software).
Thanks for all your help @bgrainger!