activerecord-cockroachdb-adapter 6.1.0.pre.beta.3 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bc55cc2cb9bfa57e9e0d5757aa2e4e892361b68f9f216de0627d3fc01c165dd
4
- data.tar.gz: 36582fada5f267b47c827c6b30112c8db955cac8606b3ae5d9c3f73cb77c9424
3
+ metadata.gz: 50e75b02ff521bc6e8988549a1ceaa7bbd8ed3eddb138e3fdd6f0d7f91b50e23
4
+ data.tar.gz: f67eac0c8dce552a8c5270d6c0740281fb9853ccde09ed53ebfc4bac21904cc7
5
5
  SHA512:
6
- metadata.gz: c23656edaccbd223d6573d1a3636263d779ae437b5628d657cd5ed2c0d7773dfa75ea52fd7b228cf06fce477ee35ea9179fa612716dc9d5bbf893d78a8dee797
7
- data.tar.gz: 566d24599b0a74edec6bdba172639130b4d6a92dc688870ee9848d124f4523ea400bf334bfa017e92cdc289f39e06c951301f1a8deb2dc74e7b0889cd617b08e
6
+ metadata.gz: 5ee1478689e350aeb60b9397c106c3576582d9ac8d33af80b4e721f5dfb6aa1509c149250f16869db85fe5ff5b3db3542da0575ad95517681d55fa77db815b19
7
+ data.tar.gz: 57ba40b8ca956807626b147592f55b1b193fffbcc5947ea47a11e1830f42a231a08dc0393c3f80fded3035b1897b0fa5579f37da27e97f83809946c692156766
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.1.0 - 2021-04-26
4
+
5
+ - Add a telemetry query on start-up. This helps the Cockroach Labs team
6
+ prioritize support for the adapter. It can be disabled by setting the
7
+ `disable_cockroachdb_telemetry` configuration option to false.
8
+
3
9
  ## 6.1.0-beta.3 - 2021-04-02
4
10
 
5
11
  - Added a configuration option named `use_follower_reads_for_type_introspection`.
data/README.md CHANGED
@@ -27,6 +27,7 @@ development:
27
27
  In addition to the standard adapter settings, CockroachDB also supports the following:
28
28
 
29
29
  - `use_follower_reads_for_type_introspection`: Use follower reads on queries to the `pg_type` catalog when set to `true`. This helps to speed up initialization by reading historical data, but may not find recently created user-defined types.
30
+ - `disable_cockroachdb_telemetry`: Determines if a telemetry call is made to the database when the connection pool is initialized. Setting this to `true` will prevent the call from being made.
30
31
 
31
32
  ## Working with Spatial Data
32
33
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "activerecord-cockroachdb-adapter"
7
- spec.version = "6.1.0-beta.3"
7
+ spec.version = "6.1.0"
8
8
  spec.licenses = ["Apache-2.0"]
9
9
  spec.authors = ["Cockroach Labs"]
10
10
  spec.email = ["cockroach-db@googlegroups.com"]
@@ -11,6 +11,7 @@ connections:
11
11
  user: root
12
12
  requiressl: disable
13
13
  min_messages: warning
14
+ disable_cockroachdb_telemetry: true
14
15
  arunit_without_prepared_statements:
15
16
  database: activerecord_unittest
16
17
  host: localhost
@@ -19,6 +20,7 @@ connections:
19
20
  requiressl: disable
20
21
  min_messages: warning
21
22
  prepared_statements: false
23
+ disable_cockroachdb_telemetry: true
22
24
  arunit2:
23
25
  database: activerecord_unittest2
24
26
  host: localhost
@@ -26,3 +28,4 @@ connections:
26
28
  user: root
27
29
  requiressl: disable
28
30
  min_messages: warning
31
+ disable_cockroachdb_telemetry: true
@@ -56,6 +56,30 @@ end
56
56
 
57
57
  module ActiveRecord
58
58
  module ConnectionAdapters
59
+ module CockroachDBConnectionPool
60
+ def initialize(pool_config)
61
+ super(pool_config)
62
+ disable_telemetry = pool_config.db_config.configuration_hash[:disable_cockroachdb_telemetry]
63
+ adapter = pool_config.db_config.configuration_hash[:adapter]
64
+ return if disable_telemetry || adapter != "cockroachdb"
65
+
66
+ with_connection do |conn|
67
+ if conn.active?
68
+ begin
69
+ query = "SELECT crdb_internal.increment_feature_counter('ActiveRecord %d.%d')"
70
+ conn.execute(query % [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR])
71
+ rescue ActiveRecord::StatementInvalid
72
+ # The increment_feature_counter built-in is not supported on this
73
+ # CockroachDB version. Ignore.
74
+ rescue StandardError => e
75
+ conn.logger.warn "Unexpected error when incrementing feature counter: #{e}"
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ ConnectionPool.prepend(CockroachDBConnectionPool)
82
+
59
83
  class CockroachDBAdapter < PostgreSQLAdapter
60
84
  ADAPTER_NAME = "CockroachDB".freeze
61
85
  DEFAULT_PRIMARY_KEY = "rowid"
@@ -194,6 +218,7 @@ module ActiveRecord
194
218
 
195
219
  def initialize(connection, logger, conn_params, config)
196
220
  super(connection, logger, conn_params, config)
221
+
197
222
  crdb_version_string = query_value("SHOW crdb_version")
198
223
  if crdb_version_string.include? "v1."
199
224
  version_num = 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-cockroachdb-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0.pre.beta.3
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cockroach Labs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-02 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -111,9 +111,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - ">"
114
+ - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: 1.3.1
116
+ version: '0'
117
117
  requirements: []
118
118
  rubygems_version: 3.1.4
119
119
  signing_key: