Skip to content

Commit d9bfffc

Browse files
committed
merged
2 parents 790fb92 + a96ca50 commit d9bfffc

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

lib/active_record/connection_adapters/cockroachdb_adapter.rb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ def supports_string_to_array_coercion?
173173
@crdb_version >= 202
174174
end
175175

176+
def supports_partitioned_indexes?
177+
false
178+
end
179+
176180
# This is hardcoded to 63 (as previously was in ActiveRecord 5.0) to aid in
177181
# migration from PostgreSQL to CockroachDB. In practice, this limitation
178182
# is arbitrary since CockroachDB supports index name lengths and table alias
@@ -206,16 +210,22 @@ def initialize(connection, logger, conn_params, config)
206210
end
207211
@crdb_version = version_num
208212

213+
if @config[:disable_cockroachdb_telemetry]
214+
return
215+
end
209216
Thread.new do
210-
begin
211-
query = "SELECT crdb_internal.increment_feature_counter('ActiveRecord %d.%d')"
212-
query_value(query % [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR])
213-
rescue ActiveRecord::StatementInvalid => error
214-
if error.cause.class == PG::UndefinedFunction
217+
pool.with_connection do |conn|
218+
if !conn.active?
219+
return
220+
end
221+
begin
222+
query = "SELECT crdb_internal.increment_feature_counter('ActiveRecord %d.%d')"
223+
conn.execute(query % [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR])
224+
rescue ActiveRecord::StatementInvalid
215225
# The increment_feature_counter built-in is not supported on this
216226
# CockroachDB version. Ignore.
217-
else
218-
raise error
227+
rescue => error
228+
logger.warn "Unexpected error when incrementing feature counter: #{error}"
219229
end
220230
end
221231
end

0 commit comments

Comments
 (0)