Skip to content
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

Unexpected Database Connection with wrong credentials when using sentry-rails #2389

Open
salzig opened this issue Aug 28, 2024 · 1 comment

Comments

@salzig
Copy link
Contributor

salzig commented Aug 28, 2024

Issue Description

Using

# config/initializers/sentry.rb
Sentry.init do |config|
  config.dsn = 'https://…' unless Rails.env.test?
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]

  # Set traces_sample_rate to 1.0 to capture 100%
  # of transactions for tracing.
  # We recommend adjusting this value in production.
  config.traces_sample_rate = 1.0
  # or
  # config.traces_sampler = lambda do |_context|
  #   true
  # end

  # Set profiles_sample_rate to profile 100%
  # of sampled transactions.
  # We recommend adjusting this value in production.
  config.profiles_sample_rate = 1.0
end

and starting the app (rails s) we suddenly got

Host '10.0.0.1' is blocked because of many connection errors; unblock with 'mariadb-admin flush-hosts' (Mysql2::Error)

Taking a look into the MySQL logs unveiled

Aug 28 11:25:15 server mariadbd[913]: 2024-08-28 11:25:15 10232 [Warning] Aborted connection 10232 to db: 'unconnected' user: 'unauthenticated' host: '10.0.0.1' (This connection closed normally without authentication)

Without Sentry.init we don't see that problem. DB and User in Log message are unaltered, and do not match up with configured credentials.

And I'm quite confused how something could trigger this, cause the database seems to be initialised and not initialised at the same time. Database-Server-IP is used, but Database-Credentials aren't. I'm also missing a good starting point to debug this further.

I'm not really sure this is a problem related to sentry, or the way sentry integrates itself into rails, but somehow it's triggered by the integration.

Note: IP of DB-Host was altered here, but it should be mentioned that the database doesn't run on localhost

Reproduction Steps

I don't know yet.

Expected Behavior

No error? What ever tries to connect to the database should only after connection is initialised by active record?

Actual Behavior

Something triggers a database connection with no or wrong credentials.

Ruby Version

ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin22]

SDK Version

sentry-ruby (5.19.0)

Integration and Its Version

sentry-rails (5.19.0), rails (6.1.7.8)

Sentry Config

No response

@st0012
Copy link
Collaborator

st0012 commented Oct 5, 2024

I tried using your config in a Rails 6.1.7 app but couldn't reproduce the issue.
It's expected to have a connection triggered when booting a Rails app and it's also unclear to me how having Sentry.init would make it pick up incorrect configuration.
We'll need more information on this case for further investigation. Can you provide a full backtrace of the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Product Owner
Development

No branches or pull requests

3 participants