gamma_replication 0.1.4 → 0.1.6
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/exe/gamma_replication +1 -0
- data/lib/gamma_replication/command/start.rb +48 -6
- data/lib/gamma_replication/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: cb4392908f3daf17928f115476739653bfebee77e940ac586eb17ef27e3104e3
|
4
|
+
data.tar.gz: 275c6b6227b7f1f2b700ef452cd10d5d18d079757d2390eb90e7bcfc4fd99b93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e1f56ac2bed52cf873dde8b40d54f2278f2f749a624723805af5bb37cd024da2c8cbd9a53897fb194a69fc52b090607b0cd31d72f9f990c16147cfcc4e8501f
|
7
|
+
data.tar.gz: 17ea2d1a0fa8c619871b55270394af7c69f67b3d5a21127cf7c2cabca59306fb062dd849fa4ecce44d3d4fb97c394703c8a5557192f7497c97e94bd6e06fb8d0
|
data/exe/gamma_replication
CHANGED
@@ -14,6 +14,7 @@ class GammaReplicationCLI < Thor
|
|
14
14
|
option :maxwell_config, aliases: "-m", desc: "Maxwell configuration file path", required: true
|
15
15
|
option :enable_stats, type: :boolean, desc: "Enable statistics output (default: true)"
|
16
16
|
option :stats_interval, type: :numeric, desc: "Statistics output interval in seconds (default: 10800)"
|
17
|
+
option :force, type: :boolean, desc: "Disable foreign key checks during replication", default: false
|
17
18
|
def start
|
18
19
|
GammaReplication::Command::Start.new(options).execute
|
19
20
|
end
|
@@ -3,9 +3,30 @@
|
|
3
3
|
module GammaReplication
|
4
4
|
module Command
|
5
5
|
class Start < BaseReplication
|
6
|
-
|
6
|
+
FATAL_ERROR_KEYWORDS = [
|
7
|
+
/out of memory/i,
|
8
|
+
/cannot allocate memory/i,
|
9
|
+
/memory allocation failed/i,
|
10
|
+
/no space left on device/i,
|
11
|
+
/disk full/i,
|
12
|
+
/too many open files/i,
|
13
|
+
/segmentation fault/i,
|
14
|
+
/bus error/i,
|
15
|
+
/killed/i,
|
16
|
+
/can't connect to mysql server/i,
|
17
|
+
/lost connection to mysql server/i,
|
18
|
+
/mysql server has gone away/i,
|
19
|
+
/permission denied/i,
|
20
|
+
/read-only file system/i,
|
21
|
+
/network is unreachable/i,
|
22
|
+
/connection refused/i,
|
23
|
+
/connection timed out/i
|
24
|
+
].freeze
|
25
|
+
|
26
|
+
def initialize(opts)
|
7
27
|
super
|
8
|
-
@
|
28
|
+
@force_mode = opts[:force]
|
29
|
+
@out_client.client.query("SET FOREIGN_KEY_CHECKS = 0") if @force_mode
|
9
30
|
end
|
10
31
|
|
11
32
|
def apply_mode?
|
@@ -14,13 +35,34 @@ module GammaReplication
|
|
14
35
|
|
15
36
|
def execute_query(query)
|
16
37
|
logger.info("Executing: #{query}") if ENV["DEBUG"]
|
17
|
-
|
18
|
-
|
19
|
-
|
38
|
+
retries = 0
|
39
|
+
begin
|
40
|
+
@out_client.client.query(query)
|
41
|
+
rescue StandardError => e
|
42
|
+
error_message = e.message.to_s.split("\n").first
|
43
|
+
log_msg = "Query execution failed: #{error_message.gsub(/\s+/, " ")}"
|
44
|
+
logger.error(log_msg)
|
45
|
+
|
46
|
+
if fatal_error?(error_message)
|
47
|
+
retries += 1
|
48
|
+
if retries < 3
|
49
|
+
logger.warn("Retrying due to fatal error (attempt #{retries})...")
|
50
|
+
sleep 2**retries
|
51
|
+
retry
|
52
|
+
else
|
53
|
+
logger.fatal("Fatal: unrecoverable error after #{retries} attempts. Exiting. Error: #{log_msg}")
|
54
|
+
exit(1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def fatal_error?(msg)
|
61
|
+
FATAL_ERROR_KEYWORDS.any? { |pattern| msg =~ pattern }
|
20
62
|
end
|
21
63
|
|
22
64
|
def finalize
|
23
|
-
@out_client.client.query("SET FOREIGN_KEY_CHECKS = 1")
|
65
|
+
@out_client.client.query("SET FOREIGN_KEY_CHECKS = 1") if @force_mode
|
24
66
|
super
|
25
67
|
end
|
26
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamma_replication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shinsuke Nishio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|