koyo-postgres-replication 0.1.1.pre → 0.1.3.pre
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 +4 -4
- data/.rubocop.yml +1 -0
- data/.yardoc/checksums +4 -4
- data/.yardoc/objects/root.dat +0 -0
- data/.yardopts +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -3
- data/changelog.md +18 -4
- data/koyo-postgres-replication.gemspec +7 -4
- data/lib/koyo/repl/database.rb +9 -0
- data/lib/koyo/repl/postgres_server.rb +44 -11
- data/lib/koyo/repl/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cc8e3d452d94177ba7d15d098bbb38b949c45a4e25c22562b358f2858b8d541
|
|
4
|
+
data.tar.gz: f844b6eb897ab00c079be8e09a45398532657938ab9e2ae762ddd07c67f685be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7e17ddc565bcc1badd81dd6520506578e9eaf09be4598ace88b1336b8c8d797ea01e48724bad5217faf2442bcd04b5cce23a48f5feb048adc00d055e7c912d7
|
|
7
|
+
data.tar.gz: df0fd55f7909c6c401fbef598e618cd4837b22634400931b9942c50b650cde64b275c61ecdb7b0f82ab5f620a0b82b3851d9c4e40c20e9ecf7303b9e3628282c
|
data/.rubocop.yml
CHANGED
data/.yardoc/checksums
CHANGED
|
@@ -4,11 +4,11 @@ lib/koyo/repl/mod.rb 92b54b56643b06fdc74adc65dc04460f631d4036
|
|
|
4
4
|
lib/koyo/repl/data.rb cb847585c0f439b9f645b5ebd7fa3b96e08b94ff
|
|
5
5
|
lib/koyo/repl/install.rb 9b19b7bb74d084882a1f726693bac2d693015daa
|
|
6
6
|
lib/koyo/repl/railtie.rb acb36cbbe1b386ece7567990945adecb6b6e5b80
|
|
7
|
-
lib/koyo/repl/version.rb
|
|
7
|
+
lib/koyo/repl/version.rb 45af9c57eb86c840d6c0756f1cd0b8a2f4b00ac0
|
|
8
8
|
lib/koyo/repl/data_row.rb 321caf0b080621f2d319fa152948cbe864c77294
|
|
9
9
|
lib/koyo/repl/database.rb 39a304909ccf68d69d36c84e3036debd9f29f6ec
|
|
10
|
-
lib/koyo/repl/diagnostics.rb
|
|
11
|
-
lib/koyo/repl/configuration.rb
|
|
12
|
-
lib/koyo/repl/postgres_server.rb
|
|
10
|
+
lib/koyo/repl/diagnostics.rb 93226c47642c5e20f615425aff8a0c0ba988b07b
|
|
11
|
+
lib/koyo/repl/configuration.rb 8a32f819abf035340a3997d989ccafe0751d209e
|
|
12
|
+
lib/koyo/repl/postgres_server.rb c8f557e1eec5b9be51ebd48002a3986eddbd6634
|
|
13
13
|
lib/koyo_postgres_replication.rb e3f4d905e3045b59f1f7c799d84cd9fde70eebd8
|
|
14
14
|
lib/koyo/repl/event_handler_service.rb 99b67bdcf3e0e92a04cd01bf8d05a4569b45d218
|
data/.yardoc/objects/root.dat
CHANGED
|
Binary file
|
data/.yardopts
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -36,9 +36,7 @@ wiki](https://github.com/wiseleyb/koyo-postgres-replication/wiki/Configuring-Pos
|
|
|
36
36
|
Add to Gemfile:
|
|
37
37
|
|
|
38
38
|
```
|
|
39
|
-
gem 'koyo-postgres-replication',
|
|
40
|
-
git: 'https://github.com/wiseleyb/koyo-postgres-replication',
|
|
41
|
-
require: 'koyo'
|
|
39
|
+
gem 'koyo-postgres-replication', require: 'koyo'
|
|
42
40
|
```
|
|
43
41
|
|
|
44
42
|
Then:
|
data/changelog.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Koyo Postgres Replication Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.3.pre
|
|
4
|
+
|
|
5
|
+
- republishing yanked gem
|
|
6
|
+
|
|
7
|
+
## 0.1.2.pre
|
|
8
|
+
|
|
9
|
+
- bump TargetRubyVersion for Rubocop to 3.2.2
|
|
10
|
+
- fix [Issue
|
|
11
|
+
2](https://github.com/wiseleyb/koyo-postgres-replication/issues/2) - gemspec
|
|
12
|
+
config around Yard doc
|
|
13
|
+
- Enter retry loop instead of crashing when db connection goes away
|
|
14
|
+
|
|
15
|
+
## 0.1.1.pre
|
|
16
|
+
|
|
17
|
+
- remove deprecated has_rdoc from gem spec
|
|
18
|
+
- fix [Issue 1](https://github.com/wiseleyb/koyo-postgres-replication/issues/1)
|
|
19
|
+
- remove recursive run, replace with simple loop
|
|
20
|
+
|
|
3
21
|
## 0.1.0.pre
|
|
4
22
|
|
|
5
23
|
- rails 7 plugin
|
|
@@ -12,7 +30,3 @@
|
|
|
12
30
|
- utility class for working with replication slots
|
|
13
31
|
- functional - but not tested in real life yet
|
|
14
32
|
|
|
15
|
-
## 0.1.1.pre
|
|
16
|
-
|
|
17
|
-
- remove deprecated has_rdoc from gem spec
|
|
18
|
-
- fix [Issue 1](https://github.com/wiseleyb/koyo-postgres-replication/issues/1) - remove recursive run, replace with simple loop
|
|
@@ -17,10 +17,13 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
|
|
18
18
|
spec.required_ruby_version = '>= 2.7.0'
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
spec.metadata = {
|
|
21
|
+
'bug_tracker_uri' => "#{url}/issues",
|
|
22
|
+
'changelog_uri' => "#{url}/blob/main/changelog.md",
|
|
23
|
+
'documentation' => 'https://www.rubydoc.info/github/wiseleyb/koyo-postgres-replication/main',
|
|
24
|
+
'homepage_uri' => spec.homepage,
|
|
25
|
+
'source_code_uri' => burl
|
|
26
|
+
}
|
|
24
27
|
|
|
25
28
|
spec.files = Dir.chdir(__dir__) do
|
|
26
29
|
`git ls-files -z`.split("\x0").reject do |f|
|
data/lib/koyo/repl/database.rb
CHANGED
|
@@ -19,6 +19,7 @@ module Koyo
|
|
|
19
19
|
conn_name = Koyo::Repl.config.database_name
|
|
20
20
|
|
|
21
21
|
unless conn_name
|
|
22
|
+
ActiveRecord::Base.establish_connection
|
|
22
23
|
@conn = ActiveRecord::Base.connection
|
|
23
24
|
return @conn
|
|
24
25
|
end
|
|
@@ -35,6 +36,14 @@ module Koyo
|
|
|
35
36
|
@conn
|
|
36
37
|
end
|
|
37
38
|
|
|
39
|
+
# Attempts to re-establish db connection
|
|
40
|
+
# This would be used when something happens like the postgres
|
|
41
|
+
# server restarts
|
|
42
|
+
def re_establish_conn
|
|
43
|
+
@conn = nil
|
|
44
|
+
conn
|
|
45
|
+
end
|
|
46
|
+
|
|
38
47
|
# Reads from the replication slot.
|
|
39
48
|
# Reading from this marks the rows read (so you won't see them again)
|
|
40
49
|
# For testing you can use `peek_slot` if you want to - which will keep
|
|
@@ -51,24 +51,57 @@ module Koyo
|
|
|
51
51
|
tick_tock
|
|
52
52
|
# Possibly fatal errors
|
|
53
53
|
rescue ActiveRecord::StatementInvalid => e
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
log_repl_fatal(msg, err: e)
|
|
58
|
-
break
|
|
59
|
-
else
|
|
60
|
-
log_recoverable_error(e)
|
|
61
|
-
end
|
|
62
|
-
# recoverable error
|
|
54
|
+
Koyo::Repl::EventHandlerService.koyo_error(e)
|
|
55
|
+
@retry = 0
|
|
56
|
+
break unless attempt_reconnect(e)
|
|
63
57
|
rescue StandardError => e
|
|
64
58
|
log_recoverable_error(e)
|
|
65
59
|
end
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
break unless success
|
|
61
|
+
break unless sleep_success?
|
|
69
62
|
end
|
|
70
63
|
end
|
|
71
64
|
|
|
65
|
+
# Attempts to re-establish DB connection. If it finds any other
|
|
66
|
+
# error this is fatal and server crashes at this point
|
|
67
|
+
# @param [StandardError] err Error that kicked off this retry loop
|
|
68
|
+
def attempt_reconnect(err)
|
|
69
|
+
@retry ||= 0
|
|
70
|
+
msg = "Error: Attempting to reconnect to DB. Retry: #{@retry}."
|
|
71
|
+
log_recoverable_error(err)
|
|
72
|
+
|
|
73
|
+
return false unless sleep_success?
|
|
74
|
+
|
|
75
|
+
Koyo::Repl::Database.re_establish_conn
|
|
76
|
+
msg = 'Re-established DB connection'
|
|
77
|
+
log_repl_info(msg)
|
|
78
|
+
true
|
|
79
|
+
rescue StandardError => e
|
|
80
|
+
unless bad_connection_error?(e)
|
|
81
|
+
msg = 'Fatal: Found erorr unrelated to PG::ConnectionBad while '\
|
|
82
|
+
"trying to reconnect: Error: #{e.message}"
|
|
83
|
+
log_repl_fatal(msg, err: e)
|
|
84
|
+
return false
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
@retry += 1
|
|
88
|
+
retry
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Test error to see if it's db:connection related
|
|
92
|
+
# Mostly here for specs
|
|
93
|
+
# @param [StandardError] err Error to check
|
|
94
|
+
def bad_connection_error?(err)
|
|
95
|
+
err.cause.exception.is_a?(PG::ConnectionBad)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Did sleep succeed... this fails when you do something like hit
|
|
99
|
+
# ctrl-c on the server
|
|
100
|
+
# Mostly here for specs
|
|
101
|
+
def sleep_success?
|
|
102
|
+
system("sleep #{Koyo::Repl.config.sql_delay}")
|
|
103
|
+
end
|
|
104
|
+
|
|
72
105
|
# Handles erros that aren't fatal. Calls back to
|
|
73
106
|
# Koyo::Repl::Log@log_repl_error which calls back
|
|
74
107
|
# to KoyoReplHandlerServer@log_repl_error
|
data/lib/koyo/repl/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: koyo-postgres-replication
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3.pre
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Wiseley
|
|
@@ -115,6 +115,7 @@ files:
|
|
|
115
115
|
- ".yardoc/object_types"
|
|
116
116
|
- ".yardoc/objects/root.dat"
|
|
117
117
|
- ".yardoc/proxy_types"
|
|
118
|
+
- ".yardopts"
|
|
118
119
|
- Gemfile
|
|
119
120
|
- Gemfile.lock
|
|
120
121
|
- MIT-LICENSE
|
|
@@ -143,7 +144,9 @@ homepage: https://github.com/wiseleyb
|
|
|
143
144
|
licenses:
|
|
144
145
|
- MIT
|
|
145
146
|
metadata:
|
|
146
|
-
|
|
147
|
+
bug_tracker_uri: https://github.com/wiseleyb/koyo-postgres-replication/issues
|
|
148
|
+
changelog_uri: https://github.com/wiseleyb/koyo-postgres-replication/blob/main/changelog.md
|
|
149
|
+
documentation: https://www.rubydoc.info/github/wiseleyb/koyo-postgres-replication/main
|
|
147
150
|
homepage_uri: https://github.com/wiseleyb
|
|
148
151
|
source_code_uri: https://github.com/wiseleyb
|
|
149
152
|
post_install_message:
|