pgoutput-client 0.3.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -1
- data/lib/pgoutput/client/runner.rb +7 -9
- data/lib/pgoutput/client/slot_inspector.rb +8 -1
- data/lib/pgoutput/client/slot_status.rb +11 -19
- data/lib/pgoutput/client/version.rb +1 -1
- data/lib/pgoutput/client/xlog_data.rb +1 -1
- data/sig/pgoutput/client/slot_status.rbs +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a79d1b00595418c8536658073164d8c4d29ad90fe79f5ba58b04e4ee80dd90a1
|
|
4
|
+
data.tar.gz: 436b7bd8d0aedae584d4b5f702635cca25f96d78857fd736c3fde5d41d1be52d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea61369e9d3ce153ce50b1f24e7335914feb898ca3e52cea20cdb0aa9875ad88a20342b2badc35c81a6fb95a941e8f36ebfdb3e3762c4f3ff421cd9cc4bfed3a
|
|
7
|
+
data.tar.gz: fb24fa3565d7d626282c5d8bdd3b5502b9cd22d168359522b741990a0d1dd10e616e921a65c3dc92beefcbcae5470484872a21a6caba6420b47d3079af62e930
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -254,6 +254,7 @@ if status.nil?
|
|
|
254
254
|
else
|
|
255
255
|
puts status.restart_lsn
|
|
256
256
|
puts status.confirmed_flush_lsn
|
|
257
|
+
puts status.retained_wal_bytes
|
|
257
258
|
puts status.wal_status
|
|
258
259
|
puts status.invalidation_reason
|
|
259
260
|
end
|
|
@@ -278,7 +279,7 @@ WAL position, retention, and invalidation fields including:
|
|
|
278
279
|
|
|
279
280
|
- `slot_name`, `plugin`, `slot_type`, and `database`
|
|
280
281
|
- `active`, `active_pid`, and `inactive_since`
|
|
281
|
-
- `restart_lsn` and `
|
|
282
|
+
- `restart_lsn`, `confirmed_flush_lsn`, and `retained_wal_bytes`
|
|
282
283
|
- `wal_status`, `safe_wal_size`, and `catalog_xmin`
|
|
283
284
|
- `conflicting` and `invalidation_reason`
|
|
284
285
|
|
|
@@ -111,15 +111,13 @@ module Pgoutput
|
|
|
111
111
|
|
|
112
112
|
loop do
|
|
113
113
|
current_configuration = configuration_for_resume
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
sleep(reconnect_backoff_for(@reconnect_attempts))
|
|
122
|
-
end
|
|
114
|
+
result = run_stream_cycle(current_configuration, &block)
|
|
115
|
+
break if result == :done
|
|
116
|
+
|
|
117
|
+
@reconnect_attempts += 1
|
|
118
|
+
raise @last_error if @reconnect_attempts > DEFAULT_RECONNECT_ATTEMPTS
|
|
119
|
+
|
|
120
|
+
sleep(reconnect_backoff_for(@reconnect_attempts))
|
|
123
121
|
end
|
|
124
122
|
ensure
|
|
125
123
|
@running = false
|
|
@@ -18,7 +18,14 @@ module Pgoutput
|
|
|
18
18
|
#
|
|
19
19
|
# @return [String]
|
|
20
20
|
QUERY = <<~SQL
|
|
21
|
-
SELECT
|
|
21
|
+
SELECT
|
|
22
|
+
to_jsonb(slot) || jsonb_build_object(
|
|
23
|
+
'retained_wal_bytes',
|
|
24
|
+
CASE
|
|
25
|
+
WHEN slot.restart_lsn IS NULL THEN NULL
|
|
26
|
+
ELSE pg_wal_lsn_diff(pg_current_wal_lsn(), slot.restart_lsn)::bigint
|
|
27
|
+
END
|
|
28
|
+
) AS slot
|
|
22
29
|
FROM pg_catalog.pg_replication_slots AS slot
|
|
23
30
|
WHERE slot.slot_name = $1
|
|
24
31
|
SQL
|
|
@@ -20,6 +20,7 @@ module Pgoutput
|
|
|
20
20
|
:catalog_xmin,
|
|
21
21
|
:restart_lsn,
|
|
22
22
|
:confirmed_flush_lsn,
|
|
23
|
+
:retained_wal_bytes,
|
|
23
24
|
:wal_status,
|
|
24
25
|
:safe_wal_size,
|
|
25
26
|
:inactive_since,
|
|
@@ -36,27 +37,18 @@ module Pgoutput
|
|
|
36
37
|
# @param attributes [Hash{String, Symbol=>Object}] catalog attributes
|
|
37
38
|
# @return [SlotStatus]
|
|
38
39
|
def self.from_catalog(attributes)
|
|
39
|
-
|
|
40
|
-
next attributes[key] if attributes.key?(key)
|
|
41
|
-
|
|
42
|
-
attributes[key.to_sym]
|
|
43
|
-
end
|
|
40
|
+
value = ->(key) { attributes.fetch(key) { attributes[key.to_sym] } }
|
|
44
41
|
|
|
45
42
|
new(
|
|
46
|
-
slot_name:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
wal_status: fetch.call("wal_status"),
|
|
56
|
-
safe_wal_size: fetch.call("safe_wal_size"),
|
|
57
|
-
inactive_since: fetch.call("inactive_since"),
|
|
58
|
-
conflicting: fetch.call("conflicting"),
|
|
59
|
-
invalidation_reason: fetch.call("invalidation_reason")
|
|
43
|
+
slot_name: value.call("slot_name"), plugin: value.call("plugin"),
|
|
44
|
+
slot_type: value.call("slot_type"), database: value.call("database"),
|
|
45
|
+
active: value.call("active") == true, active_pid: value.call("active_pid"),
|
|
46
|
+
catalog_xmin: value.call("catalog_xmin"), restart_lsn: value.call("restart_lsn"),
|
|
47
|
+
confirmed_flush_lsn: value.call("confirmed_flush_lsn"),
|
|
48
|
+
retained_wal_bytes: value.call("retained_wal_bytes"),
|
|
49
|
+
wal_status: value.call("wal_status"), safe_wal_size: value.call("safe_wal_size"),
|
|
50
|
+
inactive_since: value.call("inactive_since"), conflicting: value.call("conflicting"),
|
|
51
|
+
invalidation_reason: value.call("invalidation_reason")
|
|
60
52
|
)
|
|
61
53
|
end
|
|
62
54
|
end
|
|
@@ -44,7 +44,7 @@ module Pgoutput
|
|
|
44
44
|
wal_start = unpack_u64(binary, 1)
|
|
45
45
|
wal_end = unpack_u64(binary, 9)
|
|
46
46
|
server_clock = unpack_u64(binary, 17)
|
|
47
|
-
payload = binary.
|
|
47
|
+
payload = binary.unpack1("@25a*").freeze
|
|
48
48
|
|
|
49
49
|
Ractor.make_shareable(new(wal_start, wal_end, server_clock, payload))
|
|
50
50
|
end
|
|
@@ -10,6 +10,7 @@ module Pgoutput
|
|
|
10
10
|
attr_reader catalog_xmin: String?
|
|
11
11
|
attr_reader restart_lsn: String?
|
|
12
12
|
attr_reader confirmed_flush_lsn: String?
|
|
13
|
+
attr_reader retained_wal_bytes: Integer?
|
|
13
14
|
attr_reader wal_status: String?
|
|
14
15
|
attr_reader safe_wal_size: Integer?
|
|
15
16
|
attr_reader inactive_since: String?
|
|
@@ -26,6 +27,7 @@ module Pgoutput
|
|
|
26
27
|
catalog_xmin: String?,
|
|
27
28
|
restart_lsn: String?,
|
|
28
29
|
confirmed_flush_lsn: String?,
|
|
30
|
+
retained_wal_bytes: Integer?,
|
|
29
31
|
wal_status: String?,
|
|
30
32
|
safe_wal_size: Integer?,
|
|
31
33
|
inactive_since: String?,
|