Skip to content

Commit aa80525

Browse files
keithdoggettotan
authored andcommitted
Rescue from NoDatabaseError around telemetry call
1 parent fb49ec3 commit aa80525

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

lib/active_record/connection_adapters/cockroachdb_adapter.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,23 @@ def initialize(spec)
5858
adapter = spec.config[:adapter]
5959
return if disable_telemetry || adapter != "cockroachdb"
6060

61-
with_connection do |conn|
62-
if conn.active?
63-
begin
64-
query = "SELECT crdb_internal.increment_feature_counter('ActiveRecord %d.%d')"
65-
conn.execute(query % [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR])
66-
rescue ActiveRecord::StatementInvalid
67-
# The increment_feature_counter built-in is not supported on this
68-
# CockroachDB version. Ignore.
69-
rescue StandardError => e
70-
conn.logger.warn "Unexpected error when incrementing feature counter: #{e}"
61+
62+
begin
63+
with_connection do |conn|
64+
if conn.active?
65+
begin
66+
query = "SELECT crdb_internal.increment_feature_counter('ActiveRecord %d.%d')"
67+
conn.execute(query % [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR])
68+
rescue ActiveRecord::StatementInvalid
69+
# The increment_feature_counter built-in is not supported on this
70+
# CockroachDB version. Ignore.
71+
rescue StandardError => e
72+
conn.logger.warn "Unexpected error when incrementing feature counter: #{e}"
73+
end
7174
end
7275
end
76+
rescue ActiveRecord::NoDatabaseError
77+
# Prevent failures on db creation and parallel testing.
7378
end
7479
end
7580
end

0 commit comments

Comments
 (0)