activerecord-cockroachdb-adapter 6.0.0.pre.beta.5 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e242232ac6fcfc87b6bddc17eeb852099a959d3a024064ed3a32e85bd80ad786
4
- data.tar.gz: 5ab114df9f5fee7fb5c18c5cf0eb0dfdc822f7513f19d79312f65e0b55e1e459
3
+ metadata.gz: 4d570f0cc045c61b9fb3fd82bfa64462f34aa086295dff104b559f52e4b6b5ef
4
+ data.tar.gz: 9995b9883f98e7eba7f429f977eadc8001d3d4e91aa6b7e3eb4d8976f9e78ff1
5
5
  SHA512:
6
- metadata.gz: a2de1e036b53ebeb11185eaeb10bd465f9a1103a34307354bc4bbbe94b8beb4c5a2313938e01703db8b68f5a689ee6b9b778b8282bceac3bb852b6569340351b
7
- data.tar.gz: 4138ea2ccad0bac070c277adb9ec4aa837be440900f72fe8f2728bac78d58a96d96ed7df9a830841b3389e5f51678dba9377e0598b3aa96d682d36c609dcedfb
6
+ metadata.gz: 6c2ec381be5f87497c1dd10521956475ebe8ed57b013e89296d29afc1b30764ef18952cafa7127b02df0dba6c8eb97315819e42d658235f41bccf5c86fd2b46c
7
+ data.tar.gz: 675854788950b2182be1e44864f2a2b03ef768ace4346660f2075437de4ee90dc28717e48d7346d23cece34b9aabb8c493cfa6d93fce494c02b396ad19f3a002
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.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.0.0-beta.5 - 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.0.0-beta.5"
7
+ spec.version = "6.0.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
@@ -51,6 +51,30 @@ end
51
51
 
52
52
  module ActiveRecord
53
53
  module ConnectionAdapters
54
+ module CockroachDBConnectionPool
55
+ def initialize(spec)
56
+ super(spec)
57
+ disable_telemetry = spec.config[:disable_cockroachdb_telemetry]
58
+ adapter = spec.config[:adapter]
59
+ return if disable_telemetry || adapter != "cockroachdb"
60
+
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}"
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ ConnectionPool.prepend(CockroachDBConnectionPool)
77
+
54
78
  class CockroachDBAdapter < PostgreSQLAdapter
55
79
  ADAPTER_NAME = "CockroachDB".freeze
56
80
  DEFAULT_PRIMARY_KEY = "rowid"
@@ -239,6 +263,7 @@ module ActiveRecord
239
263
 
240
264
  def initialize(connection, logger, conn_params, config)
241
265
  super(connection, logger, conn_params, config)
266
+
242
267
  crdb_version_string = query_value("SHOW crdb_version")
243
268
  if crdb_version_string.include? "v1."
244
269
  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.0.0.pre.beta.5
4
+ version: 6.0.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-05 00:00:00.000000000 Z
11
+ date: 2021-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -110,9 +110,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ">"
113
+ - - ">="
114
114
  - !ruby/object:Gem::Version
115
- version: 1.3.1
115
+ version: '0'
116
116
  requirements: []
117
117
  rubygems_version: 3.1.4
118
118
  signing_key: