-
Notifications
You must be signed in to change notification settings - Fork 31
Fix: Fail early when database server does not respond #711
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
base: main
Are you sure you want to change the base?
Conversation
""" WalkthroughThe changes update the connection logic to fail early when the database server is unresponsive, by raising the last encountered connection error if no valid server version is found. The changelog is updated to reflect this. Additionally, a new test is introduced to verify that connection errors are properly raised for invalid server addresses. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Connection
participant Server
Client->>Connection: connect()
loop For each server
Connection->>Server: request server version
alt Server responds with version
Connection->>Connection: store version if valid
else Server not available (ConnectionError)
Connection->>Connection: store last ConnectionError
else Invalid version (ValueError/InvalidVersion)
Connection->>Connection: ignore and continue
end
end
alt No valid server version found and ConnectionError occurred
Connection-->>Client: raise last ConnectionError
else Valid server version found
Connection-->>Client: proceed with connection
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (10)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Problem
@shraik started using sqlalchemy-cratedb and reported that its behaviour deviates from other vendors by not failing on
engine.connect()
when the database server is not available.We found this is not actually on the SQLAlchemy dialect, but on the DBAPI driver already, which exhibits the same behaviour.
Solution
The patch extends the
_lowest_server_version
method to re-raise the lastConnectionError
when no connection can be made to any configured server node. By doing it this way, we didn't need to submit a dummy SQL command like planned. It is much better this way because it does not pollute the server-side statement log./cc @surister