litebackup 1.5.0-x86_64-linux-gnu → 1.6.0-x86_64-linux-gnu
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/lib/litebackup/bin/litebackup +2 -2
- data/lib/litebackup/client.rb +4 -4
- data/lib/litebackup/failover.rb +8 -8
- data/lib/litebackup/generated/models.rb +3 -3
- data/lib/litebackup/launch.rb +9 -9
- data/lib/litebackup/version.rb +2 -2
- 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: 21904231ea369be615b47939c3ce6943552a99d27a12044af873f8b8fbe1f1a8
|
|
4
|
+
data.tar.gz: 8e8ccd2791b9cb68cc43a0ce71a06a5502258d890ff2ac5a77c1d23c9698dde7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d8f043851cb162a6e24d3d012a426fcae18a81b588884eb5645a3e4cef9fa574e159199d5efdf838cec95f6120d820195c7822cbdaa2e9b36c70cd59345d52be
|
|
7
|
+
data.tar.gz: 4b09cb29fef16e7a98c6e084c46b42fb8a68ec60d62fc6209491cae5d99fb3d3d4f2732f9067ea6c6c50aebb1008e56fde7fd1a8980c6b29fd1e323838ae911e
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: data/lib/litebackup/bin/litebackup
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 56846704 bytes
|
|
4
|
+
sha256: e08c787bb1d0746a38b1a3868627d8195bbbd44d1cc2483d51ffec533363e655
|
data/lib/litebackup/client.rb
CHANGED
|
@@ -117,7 +117,7 @@ module Litebackup
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
# Connects, starting the daemon when needed; fails with daemon_unsupported
|
|
120
|
-
# for a daemon older than 1.
|
|
120
|
+
# for a daemon older than 1.6.0.
|
|
121
121
|
def connect
|
|
122
122
|
ensure_open
|
|
123
123
|
@connect_lock.synchronize do
|
|
@@ -500,18 +500,18 @@ module Litebackup
|
|
|
500
500
|
# Runs the database at path, the same on every machine; returns once this
|
|
501
501
|
# machine is the origin or has a replica. See Failover for the callbacks:
|
|
502
502
|
# on_role_change hears the role the start answered, then every change;
|
|
503
|
-
#
|
|
503
|
+
# on_denied hears the daemon's message when it refused this machine's
|
|
504
504
|
# file; on_error hears each failed read. A file at the path that differs
|
|
505
505
|
# from the server head, and is not a clean copy of the version this
|
|
506
506
|
# machine last synced, is refused with conflict and left untouched;
|
|
507
507
|
# discard_local replaces it with the head.
|
|
508
|
-
def start(path, name: nil, timeout: nil, discard_local: false, on_role_change: nil,
|
|
508
|
+
def start(path, name: nil, timeout: nil, discard_local: false, on_role_change: nil, on_denied: nil, on_error: nil)
|
|
509
509
|
call = Wire.start_failover(path, name: name, timeout: timeout, discard_local: discard_local)
|
|
510
510
|
log_end = @client.call(Wire.events_page(after: -1))
|
|
511
511
|
started = @client.call(call)
|
|
512
512
|
@client.ensure_open
|
|
513
513
|
failover = Failover.new(@client, started, log_end.next, on_role_change: on_role_change,
|
|
514
|
-
|
|
514
|
+
on_denied: on_denied, on_error: on_error)
|
|
515
515
|
@client.add_failover(failover)
|
|
516
516
|
failover.start_following
|
|
517
517
|
failover
|
data/lib/litebackup/failover.rb
CHANGED
|
@@ -23,8 +23,8 @@ module Litebackup
|
|
|
23
23
|
EVENT_PAGE = 1000
|
|
24
24
|
ROLE_CHANGED = Models::EventType::ROLE_CHANGED
|
|
25
25
|
DRAINING = Models::EventType::DRAINING
|
|
26
|
-
|
|
27
|
-
ROLE_EVENT_TYPES = [ROLE_CHANGED, DRAINING,
|
|
26
|
+
DENIED = Models::EventType::DENIED
|
|
27
|
+
ROLE_EVENT_TYPES = [ROLE_CHANGED, DRAINING, DENIED].freeze
|
|
28
28
|
# Error codes the event reading never retries: they end following. An
|
|
29
29
|
# expired cursor is not one: a failover resumes at the log's end.
|
|
30
30
|
FATAL_ERROR_CODES = [
|
|
@@ -68,7 +68,7 @@ module Litebackup
|
|
|
68
68
|
# What the daemon answered when the failover started.
|
|
69
69
|
attr_reader :status, :name, :path
|
|
70
70
|
|
|
71
|
-
def initialize(client, status, cursor, on_role_change: nil,
|
|
71
|
+
def initialize(client, status, cursor, on_role_change: nil, on_denied: nil, on_error: nil)
|
|
72
72
|
@client = client
|
|
73
73
|
@status = status
|
|
74
74
|
@name = status.name
|
|
@@ -78,7 +78,7 @@ module Litebackup
|
|
|
78
78
|
@event_wait = Failover.event_wait_seconds
|
|
79
79
|
@confirmation_limit = Failover.confirmation_limit_seconds
|
|
80
80
|
@on_role_change = on_role_change
|
|
81
|
-
@
|
|
81
|
+
@on_denied = on_denied
|
|
82
82
|
@on_error = on_error
|
|
83
83
|
@stopped = false
|
|
84
84
|
@owner_pid = Process.pid
|
|
@@ -160,7 +160,7 @@ module Litebackup
|
|
|
160
160
|
|
|
161
161
|
# The role a status read reports: unknown while the daemon drains the
|
|
162
162
|
# origin, as after a draining event, and while the failover's file is
|
|
163
|
-
# refused (conflicted), as after a
|
|
163
|
+
# refused (conflicted), as after a denied event.
|
|
164
164
|
def status_role(database)
|
|
165
165
|
database.draining == true || database.state == Wire::STATE_CONFLICTED ? UNKNOWN : database.role
|
|
166
166
|
end
|
|
@@ -189,7 +189,7 @@ module Litebackup
|
|
|
189
189
|
# An event older than the last role read changes no role, because
|
|
190
190
|
# that read has it; a refusal among them is still reported.
|
|
191
191
|
older_than_role_read = role_event?(event.type) && event.id <= progress.role_read_log_end
|
|
192
|
-
return if older_than_role_read && event.type !=
|
|
192
|
+
return if older_than_role_read && event.type != DENIED
|
|
193
193
|
|
|
194
194
|
case event.type
|
|
195
195
|
when ROLE_CHANGED
|
|
@@ -199,12 +199,12 @@ module Litebackup
|
|
|
199
199
|
# the lock, so the app stops writing while no machine is allowed to
|
|
200
200
|
# take over yet.
|
|
201
201
|
change_role(UNKNOWN)
|
|
202
|
-
when
|
|
202
|
+
when DENIED
|
|
203
203
|
# The daemon refused this machine's file and the failover stays
|
|
204
204
|
# conflicted there: this machine neither writes nor follows the database.
|
|
205
205
|
change_role(UNKNOWN) unless older_than_role_read
|
|
206
206
|
# The role callback could have stopped the failover.
|
|
207
|
-
@
|
|
207
|
+
@on_denied.call(event.message) if !@stopped && !@on_denied.nil?
|
|
208
208
|
end
|
|
209
209
|
end
|
|
210
210
|
end
|
|
@@ -7,11 +7,12 @@ module Litebackup
|
|
|
7
7
|
module Models
|
|
8
8
|
# What happened to a database: role_changed (role is origin or replica, and message is text),
|
|
9
9
|
# draining (a failover origin stops being the origin before a drain releases its lock: its role
|
|
10
|
-
# is unknown until the next role_changed),
|
|
10
|
+
# is unknown until the next role_changed), denied (path names the refused file, such as a
|
|
11
11
|
# failover's file that holds writes the server lacks), path_unreadable (path names the path a
|
|
12
12
|
# backup rule could not read), and the others by their names.
|
|
13
13
|
module EventType
|
|
14
14
|
ACQUIRED = "acquired"
|
|
15
|
+
DENIED = "denied"
|
|
15
16
|
DOWNLOAD_FINISHED = "download_finished"
|
|
16
17
|
DOWNLOAD_STARTED = "download_started"
|
|
17
18
|
DRAINING = "draining"
|
|
@@ -21,7 +22,6 @@ module Litebackup
|
|
|
21
22
|
OFFLOADED = "offloaded"
|
|
22
23
|
PATH_UNREADABLE = "path_unreadable"
|
|
23
24
|
REBASED = "rebased"
|
|
24
|
-
REFUSED = "refused"
|
|
25
25
|
RELEASED = "released"
|
|
26
26
|
REPLICATING = "replicating"
|
|
27
27
|
RESTORED = "restored"
|
|
@@ -33,6 +33,7 @@ module Litebackup
|
|
|
33
33
|
TRACKED = "tracked"
|
|
34
34
|
ALL = [
|
|
35
35
|
ACQUIRED,
|
|
36
|
+
DENIED,
|
|
36
37
|
DOWNLOAD_FINISHED,
|
|
37
38
|
DOWNLOAD_STARTED,
|
|
38
39
|
DRAINING,
|
|
@@ -42,7 +43,6 @@ module Litebackup
|
|
|
42
43
|
OFFLOADED,
|
|
43
44
|
PATH_UNREADABLE,
|
|
44
45
|
REBASED,
|
|
45
|
-
REFUSED,
|
|
46
46
|
RELEASED,
|
|
47
47
|
REPLICATING,
|
|
48
48
|
RESTORED,
|
data/lib/litebackup/launch.rb
CHANGED
|
@@ -49,9 +49,9 @@ module Litebackup
|
|
|
49
49
|
# JSON: drain_required when the launch refused a new credential for a
|
|
50
50
|
# client that has write locks, and launch_failed otherwise, also with the
|
|
51
51
|
# whole output when the command reported no error as JSON.
|
|
52
|
-
def
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
def launch_denial(output)
|
|
53
|
+
denial = ""
|
|
54
|
+
denial_code = ErrorCode::LAUNCH_FAILED
|
|
55
55
|
output.each_line do |line|
|
|
56
56
|
diagnostic = begin
|
|
57
57
|
JSON.parse(line)
|
|
@@ -64,17 +64,17 @@ module Litebackup
|
|
|
64
64
|
message = diagnostic["message"]
|
|
65
65
|
next unless message.is_a?(String) && !message.empty?
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
denial = message
|
|
68
|
+
denial_code = diagnostic["code"] == ErrorCode::DRAIN_REQUIRED ? ErrorCode::DRAIN_REQUIRED : ErrorCode::LAUNCH_FAILED
|
|
69
69
|
end
|
|
70
|
-
return [ErrorCode::LAUNCH_FAILED, output.strip] if
|
|
70
|
+
return [ErrorCode::LAUNCH_FAILED, output.strip] if denial.empty?
|
|
71
71
|
|
|
72
|
-
[
|
|
72
|
+
[denial_code, denial]
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def launch_failed(output, cause)
|
|
76
|
-
code,
|
|
77
|
-
Error.new(code, "starting Litebackup failed: #{
|
|
76
|
+
code, denial = launch_denial(output)
|
|
77
|
+
Error.new(code, "starting Litebackup failed: #{denial.empty? ? cause : denial}")
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
# Starts the session daemon when nothing listens on its socket.
|
data/lib/litebackup/version.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Litebackup
|
|
4
4
|
# Sent with every call. Daemons refuse SDKs older than their minimum with sdk_unsupported.
|
|
5
|
-
VERSION = "1.
|
|
5
|
+
VERSION = "1.6.0"
|
|
6
6
|
# Connecting to an older daemon fails with daemon_unsupported.
|
|
7
|
-
MINIMUM_DAEMON_VERSION = "1.
|
|
7
|
+
MINIMUM_DAEMON_VERSION = "1.6.0"
|
|
8
8
|
end
|