Comments (6)
Adding specific exceptions sounds good. Feel free to send a PR or explain what use cases you have in mind.
from crystal-mysql.
The context is:
I'm utilizing this shard within another small shard (run as an executable) that connects to the database every so often (long story) within Kubernetes. Due to the raised database connection error my shard crashes, the container crashes, then the entire pod crashes.
My goal is to handle specific exceptions so as to keep the loop happy and not bring down an entire Kubernetes pod. π
I'll submit a PR later on.
from crystal-mysql.
If you use a connection pool instead of a direct connection you should be resilient to connection errors. I'm not sure how you are setting up/executing queries
from crystal-mysql.
It's mostly related to credentials which have expired. Instead of crashing due to the exception it would be better for us to handle it specifically βΒ to resolve it involves work outside of the container in question; it would eventually be killed off.
I just don't want to rescue every exception because if something more serious is happening it would be better to deal with a standard noisy crash than skipping it on by.
from crystal-mysql.
If credentials are wrong I would expect you to get a DB::ConnectionRefused. Isn't that the case?
from crystal-mysql.
Now that I think of it, I have seen DB::ConnectionRefused
, but going back the exception encountered was:
Unhandled exception: Access denied for user '[REDACTED]'@'[REDACTED]' (using password: YES) (Exception)
from app/lib/mysql/src/mysql/connection.cr:102:5 in 'handle_err_packet'
from app/lib/mysql/src/mysql/connection.cr:116:7 in 'initialize'
from app/lib/mysql/src/mysql/connection.cr:4:3 in 'new'
from app/lib/mysql/src/mysql/driver.cr:3:5 in 'build_connection'
from app/lib/db/src/db/database.cr:57:9 in '->'
from app/lib/db/src/db/pool.cr:218:27 in 'build_resource'
from app/lib/db/src/db/pool.cr:47:34 in 'initialize'
from app/lib/db/src/db/pool.cr:40:5 in 'new:initial_pool_size:max_pool_size:max_idle_pool_size:checkout_timeout:retry_attempts:retry_delay'
from app/lib/db/src/db/database.cr:56:15 in 'initialize'
from app/lib/db/src/db/database.cr:49:5 in 'new'
from app/lib/db/src/db.cr:155:5 in 'build_database'
from app/lib/db/src/db.cr:151:5 in 'build_database'
from app/lib/db/src/db.cr:124:5 in 'call'
from app/src/leash.cr:54:3 in '__crystal_main'
from usr/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
from usr/share/crystal/src/crystal/main.cr:101:7 in 'main'
from usr/share/crystal/src/crystal/main.cr:127:3 in 'main'
from /lib/ld-musl-x86_64.so.1 in '??'
from crystal-mysql.
Related Issues (20)
- Unexpected EOF on ubuntu aarch64 HOT 2
- packet 254 not implemented -- still struggling with
- Release a new version HOT 2
- Crystal 0.24 HOT 4
- call Store procedure HOT 1
- "Client does not support authentication protocol requested by server; consider upgrading MySQL client (Exception)" HOT 7
- BINARY and VARBINARY columns can only be read as string
- connection failure to mysql 8 HOT 11
- how to connect to mysql via unix_socket?
- Support JSON data type
- Register custom decoder? HOT 2
- Inconsistent return value types HOT 2
- Add support for bit(1) reading
- values of UInt8 data types get converted to 125 HOT 8
- Cannot read query_one result as Bool HOT 4
- Shards Issue : install does not work HOT 6
- Release 0.8.0 missing HOT 1
- Missing block in decl_type *Blob ?
- Support for MariaDB? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crystal-mysql.