distribute_reads 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/distribute_reads.rb +5 -5
- data/lib/distribute_reads/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3e0ef8f494561b701bc58c7119865cf0ff1693364352a218a9a2da9e0fb4060
|
4
|
+
data.tar.gz: 14b0a9907a9f0592f2c520f325ab689f3ca0eeef924ab89edef698cbbb47bcea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b0da6908431d10090a1c942357ef8bfb2fc1dfe480774dabaab873bebf6c4baea1a184d429ec7907d58b18b23c00ff947583c2b7f716055a7224bb98e3c0e0d
|
7
|
+
data.tar.gz: 2deb9025f60388bb65b03c5f4e27a7f3c8a10d9b174c463437e235a4b07f4eb8f2903e9b87c1d1b3ffd430a2ba4871bb97dc492b318ce13409f2fe775cf88c00
|
data/CHANGELOG.md
CHANGED
data/lib/distribute_reads.rb
CHANGED
@@ -45,7 +45,7 @@ module DistributeReads
|
|
45
45
|
# cache the version number
|
46
46
|
@server_version_num ||= {}
|
47
47
|
cache_key = connection.pool.object_id
|
48
|
-
@server_version_num[cache_key] ||= connection.
|
48
|
+
@server_version_num[cache_key] ||= connection.select_all("SHOW server_version_num").first["server_version_num"].to_i
|
49
49
|
|
50
50
|
lag_condition =
|
51
51
|
if @server_version_num[cache_key] >= 100000
|
@@ -54,7 +54,7 @@ module DistributeReads
|
|
54
54
|
"pg_last_xlog_receive_location() = pg_last_xlog_replay_location()"
|
55
55
|
end
|
56
56
|
|
57
|
-
connection.
|
57
|
+
connection.select_all(
|
58
58
|
"SELECT CASE
|
59
59
|
WHEN NOT pg_is_in_recovery() OR #{lag_condition} THEN 0
|
60
60
|
ELSE EXTRACT (EPOCH FROM NOW() - pg_last_xact_replay_timestamp())
|
@@ -66,14 +66,14 @@ module DistributeReads
|
|
66
66
|
|
67
67
|
unless @aurora_mysql.key?(cache_key)
|
68
68
|
# makara doesn't send SHOW queries to replica by default
|
69
|
-
@aurora_mysql[cache_key] = connection.
|
69
|
+
@aurora_mysql[cache_key] = connection.select_all("SHOW VARIABLES LIKE 'aurora_version'").any?
|
70
70
|
end
|
71
71
|
|
72
72
|
if @aurora_mysql[cache_key]
|
73
|
-
status = connection.
|
73
|
+
status = connection.select_all("SELECT Replica_lag_in_msec FROM mysql.ro_replica_status WHERE Server_id = @@aurora_server_id").first
|
74
74
|
status ? status["Replica_lag_in_msec"].to_f / 1000.0 : 0.0
|
75
75
|
else
|
76
|
-
status = connection.
|
76
|
+
status = connection.select_all("SHOW SLAVE STATUS").first
|
77
77
|
if status
|
78
78
|
if status["Seconds_Behind_Master"].nil?
|
79
79
|
# replication stopped
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: distribute_reads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: makara
|