Git Product home page Git Product logo

Comments (6)

bcardiff avatar bcardiff commented on July 24, 2024 1

Adding specific exceptions sounds good. Feel free to send a PR or explain what use cases you have in mind.

from crystal-mysql.

brodyhoskins avatar brodyhoskins commented on July 24, 2024

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.

bcardiff avatar bcardiff commented on July 24, 2024

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.

brodyhoskins avatar brodyhoskins commented on July 24, 2024

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.

bcardiff avatar bcardiff commented on July 24, 2024

If credentials are wrong I would expect you to get a DB::ConnectionRefused. Isn't that the case?

from crystal-mysql.

brodyhoskins avatar brodyhoskins commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.