Skip to content

Commit

Permalink
Merge pull request #118 from lbeder/select-1
Browse files Browse the repository at this point in the history
Use "SELECT 1" to check for DB connectivity and liveness
  • Loading branch information
lbeder authored Mar 25, 2024
2 parents 05813dc + ea7903e commit d828b9c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['2.7.7', '3.1.3']
ruby: ['3.1.4', '3.2.3', '3.3.0']

name: Ruby ${{ matrix.ruby }}
steps:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 12.0.0 (2024-03-23)

- Use "SELECT 1" to check for DB connectivity and liveness (thanks to @jayceekay)

## 11.3.0 (2024-01-21)

- Unpermitting subdomain (thanks to @shettytejas)
Expand Down
2 changes: 1 addition & 1 deletion lib/health_monitor/providers/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def check!
failed_databases = []

ActiveRecord::Base.connection_handler.connection_pool_list(:all).each do |cp|
cp.connection.check_version
cp.connection.execute('SELECT 1')
rescue Exception
failed_databases << cp.db_config.name
end
Expand Down
2 changes: 1 addition & 1 deletion lib/health_monitor/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module HealthMonitor
VERSION = '11.3.0'
VERSION = '12.0.0'
end
2 changes: 1 addition & 1 deletion spec/support/providers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def stub_cache_failure
end

def stub_database_failure(database = nil)
allow_any_instance_of(ActiveRecord::ConnectionAdapters::SQLite3Adapter).to receive(:check_version) do |instance|
allow_any_instance_of(ActiveRecord::ConnectionAdapters::SQLite3Adapter).to receive(:execute) do |instance|
raise StandardError if !database.present? || instance.pool.db_config.name == database.to_s
end
end
Expand Down

0 comments on commit d828b9c

Please sign in to comment.