lhm-shopify 3.5.5 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +20 -18
- data/Appraisals +8 -19
- data/CHANGELOG.md +16 -0
- data/Gemfile.lock +37 -20
- data/README.md +21 -14
- data/dev.yml +12 -8
- data/docker-compose-mysql-5.7.yml +1 -0
- data/docker-compose-mysql-8.0.yml +63 -0
- data/docker-compose.yml +5 -3
- data/gemfiles/activerecord_6.1.gemfile +1 -0
- data/gemfiles/activerecord_6.1.gemfile.lock +23 -13
- data/gemfiles/{activerecord_7.0.0.alpha2.gemfile → activerecord_7.0.gemfile} +2 -1
- data/gemfiles/{activerecord_7.0.0.alpha2.gemfile.lock → activerecord_7.0.gemfile.lock} +29 -19
- data/gemfiles/{activerecord_6.0.gemfile → activerecord_7.1.gemfile} +1 -1
- data/gemfiles/activerecord_7.1.gemfile.lock +83 -0
- data/lhm.gemspec +2 -1
- data/lib/lhm/atomic_switcher.rb +3 -3
- data/lib/lhm/chunker.rb +4 -4
- data/lib/lhm/connection.rb +9 -1
- data/lib/lhm/sql_helper.rb +1 -1
- data/lib/lhm/sql_retry.rb +36 -18
- data/lib/lhm/table.rb +3 -4
- data/lib/lhm/throttler/replica_lag.rb +166 -0
- data/lib/lhm/throttler/slave_lag.rb +5 -155
- data/lib/lhm/throttler/threads_running.rb +3 -1
- data/lib/lhm/throttler.rb +7 -3
- data/lib/lhm/version.rb +1 -1
- data/scripts/helpers/wait-for-dbs.sh +3 -3
- data/scripts/mysql/writer/create_users.sql +1 -1
- data/spec/.lhm.example +1 -1
- data/spec/README.md +8 -9
- data/spec/integration/atomic_switcher_spec.rb +6 -10
- data/spec/integration/chunk_insert_spec.rb +2 -2
- data/spec/integration/chunker_spec.rb +54 -44
- data/spec/integration/database.yml +4 -4
- data/spec/integration/entangler_spec.rb +4 -4
- data/spec/integration/integration_helper.rb +23 -15
- data/spec/integration/lhm_spec.rb +70 -44
- data/spec/integration/locked_switcher_spec.rb +2 -2
- data/spec/integration/proxysql_spec.rb +10 -10
- data/spec/integration/sql_retry/db_connection_helper.rb +2 -4
- data/spec/integration/sql_retry/lock_wait_spec.rb +7 -8
- data/spec/integration/sql_retry/lock_wait_timeout_test_helper.rb +18 -10
- data/spec/integration/sql_retry/proxysql_helper.rb +1 -1
- data/spec/integration/sql_retry/retry_with_proxysql_spec.rb +1 -2
- data/spec/integration/table_spec.rb +1 -1
- data/spec/integration/toxiproxy_helper.rb +1 -1
- data/spec/test_helper.rb +27 -3
- data/spec/unit/atomic_switcher_spec.rb +2 -2
- data/spec/unit/chunker_spec.rb +43 -43
- data/spec/unit/connection_spec.rb +2 -2
- data/spec/unit/entangler_spec.rb +14 -24
- data/spec/unit/printer_spec.rb +2 -6
- data/spec/unit/sql_helper_spec.rb +2 -2
- data/spec/unit/throttler/{slave_lag_spec.rb → replica_lag_spec.rb} +84 -92
- data/spec/unit/throttler/threads_running_spec.rb +18 -0
- data/spec/unit/throttler_spec.rb +8 -8
- metadata +26 -12
- data/.travis.yml +0 -21
- data/gemfiles/activerecord_5.2.gemfile +0 -9
- data/gemfiles/activerecord_5.2.gemfile.lock +0 -65
- data/gemfiles/activerecord_6.0.gemfile.lock +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 850cda6d2f610db2985c780d2a90d176e8520b373e21dafbe67df47e9a07ba0f
|
4
|
+
data.tar.gz: 982ab91c6319f5f7803d73d9f3734a57d28a13e76184500a665a5ab5b91d434f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bdb254a7cd2091f7d1d125080bc843b43fc9039a7b2a99cba62752bee84726971e8018fb77738fdd0b15867a7f959ff419802270de75c08c2a72cd44d8b004b
|
7
|
+
data.tar.gz: b7d3a989384483ba9f43dd000f1e46c62805e15a0e15c4fcba0fedc964787d4fb1eafe294a2b23deae2d5b035057739551385eca08d24529d8c8e951ba44b163
|
data/.github/workflows/test.yml
CHANGED
@@ -14,30 +14,32 @@ jobs:
|
|
14
14
|
strategy:
|
15
15
|
fail-fast: false
|
16
16
|
matrix:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
activerecord: ["6.1", "7.0", "7.1"]
|
18
|
+
ruby: ["3.0", "3.1", "3.2", "head"]
|
19
|
+
mysql: ["5.7", "8.0"]
|
20
|
+
adapter: ["mysql2", "trilogy"]
|
21
|
+
|
22
|
+
env:
|
23
|
+
BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord_${{ matrix.activerecord }}.gemfile"
|
24
|
+
DATABASE_ADAPTER: "${{ matrix.adapter }}"
|
25
|
+
|
26
26
|
steps:
|
27
|
-
- uses: actions/checkout@
|
28
|
-
-
|
29
|
-
uses: ruby/setup-ruby@v1
|
27
|
+
- uses: actions/checkout@v4
|
28
|
+
- uses: ruby/setup-ruby@v1
|
30
29
|
with:
|
31
|
-
ruby-version: ${{matrix.ruby
|
32
|
-
bundler-cache:
|
33
|
-
|
34
|
-
run: BUNDLE_GEMFILE="${GITHUB_WORKSPACE}/gemfiles/activerecord_${{ matrix.activerecord-version }}.gemfile" bundle install
|
30
|
+
ruby-version: ${{matrix.ruby}}
|
31
|
+
bundler-cache: true
|
32
|
+
|
35
33
|
- name: Install Ubuntu packages
|
36
34
|
run: sudo apt-get update && sudo apt-get install numactl libaio-dev libmysqlclient-dev
|
35
|
+
|
37
36
|
- name: Setup MySQL and ProxySQL (docker-compose)
|
38
|
-
|
37
|
+
# Might have to change to docker compose up -d (i.e. Compose V2) when the Ubuntu image changes the docker-compose version
|
38
|
+
run: docker-compose -f docker-compose-mysql-${{ matrix.mysql }}.yml up -d
|
39
|
+
|
39
40
|
- name: Wait until DBs are alive
|
40
41
|
run: ./scripts/helpers/wait-for-dbs.sh
|
41
42
|
timeout-minutes: 2
|
43
|
+
|
42
44
|
- name: Run tests
|
43
|
-
run:
|
45
|
+
run: bundle exec rake specs
|
data/Appraisals
CHANGED
@@ -1,24 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
gem "activerecord"
|
4
|
-
|
5
|
-
# This gemfile will be ran against ruby 2.4 and some gems might require 2.4+. The following list are the gems
|
6
|
-
# and their respective versions that work with ruby <= 2.4
|
7
|
-
gem "simplecov", "0.18.5"
|
8
|
-
gem "docile", "1.3.5"
|
1
|
+
appraise "activerecord-6.1" do
|
2
|
+
gem "activerecord", "6.1.0"
|
3
|
+
gem "activerecord-trilogy-adapter"
|
9
4
|
end
|
10
5
|
|
11
|
-
|
12
|
-
|
13
|
-
gem "activerecord"
|
6
|
+
appraise "activerecord-7.0" do
|
7
|
+
gem "activerecord", "7.0.8"
|
8
|
+
gem "activerecord-trilogy-adapter"
|
14
9
|
end
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
gem "activerecord", "6.1.0"
|
11
|
+
appraise "activerecord-7.1" do
|
12
|
+
gem "activerecord", "7.1.1"
|
19
13
|
end
|
20
|
-
|
21
|
-
# Latest version at the moment
|
22
|
-
appraise "activerecord-7.0.0.alpha2" do
|
23
|
-
gem "activerecord", "7.0.0.alpha2"
|
24
|
-
end
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# Unreleased
|
2
|
+
|
3
|
+
# 4.1.0 (Oct, 2023)
|
4
|
+
* Test against MySQL 8.0.
|
5
|
+
* Test against Ruby Head.
|
6
|
+
* Drop support for ActiveRecord below version 6.1, as it has reached EOL.
|
7
|
+
* Add support for Trilogy MySQL client. It's works with built in ActiveRecord adapter from Rails 7.1 on, as well as dedicated one in older Rails versions.
|
8
|
+
|
9
|
+
# 4.0.0 (Sep, 2023)
|
10
|
+
* Deprecate `SlaveLag` throttler class name. Use `ReplicaLag` instead (https://github.com/Shopify/lhm/pull/144)
|
11
|
+
* Deprecate `slave_lag_throttler` throttler config value. Use `replica_lag_throttler` instead (https://github.com/Shopify/lhm/pull/144)
|
12
|
+
* Fix errors when creating indexes with whitespace between column names and sizes. (https://github.com/Shopify/lhm/pull/145)
|
13
|
+
* Test against Ruby 3.2 and Rails 7.1.0.beta1. (https://github.com/Shopify/lhm/pull/146)
|
14
|
+
* Drop support for Ruby 2 and Rails 5. (https://github.com/Shopify/lhm/pull/148)
|
15
|
+
* Fix thread throttler #stride API. (https://github.com/Shopify/lhm/pull/131)
|
16
|
+
|
1
17
|
# 3.5.5 (Jan, 2022)
|
2
18
|
* Fix error where from Config shadowing which would cause LHM to abort on reconnect (https://github.com/Shopify/lhm/pull/128)
|
3
19
|
|
data/Gemfile.lock
CHANGED
@@ -1,51 +1,67 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lhm-shopify (
|
4
|
+
lhm-shopify (4.1.0)
|
5
5
|
retriable (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (
|
11
|
-
activesupport (=
|
12
|
-
activerecord (
|
13
|
-
activemodel (=
|
14
|
-
activesupport (=
|
15
|
-
|
10
|
+
activemodel (7.1.1)
|
11
|
+
activesupport (= 7.1.1)
|
12
|
+
activerecord (7.1.1)
|
13
|
+
activemodel (= 7.1.1)
|
14
|
+
activesupport (= 7.1.1)
|
15
|
+
timeout (>= 0.4.0)
|
16
|
+
activesupport (7.1.1)
|
17
|
+
base64
|
18
|
+
bigdecimal
|
16
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
+
connection_pool (>= 2.2.5)
|
21
|
+
drb
|
17
22
|
i18n (>= 1.6, < 2)
|
18
23
|
minitest (>= 5.1)
|
24
|
+
mutex_m
|
19
25
|
tzinfo (~> 2.0)
|
20
|
-
zeitwerk (~> 2.3)
|
21
26
|
after_do (0.4.0)
|
22
|
-
appraisal (2.
|
27
|
+
appraisal (2.5.0)
|
23
28
|
bundler
|
24
29
|
rake
|
25
30
|
thor (>= 0.14.0)
|
31
|
+
base64 (0.1.1)
|
32
|
+
bigdecimal (3.1.4)
|
26
33
|
byebug (11.1.3)
|
27
|
-
concurrent-ruby (1.
|
34
|
+
concurrent-ruby (1.2.2)
|
35
|
+
connection_pool (2.4.1)
|
28
36
|
docile (1.4.0)
|
29
|
-
|
37
|
+
drb (2.1.1)
|
38
|
+
ruby2_keywords
|
39
|
+
i18n (1.14.1)
|
30
40
|
concurrent-ruby (~> 1.0)
|
31
|
-
minitest (5.
|
32
|
-
mocha (1.
|
33
|
-
|
41
|
+
minitest (5.20.0)
|
42
|
+
mocha (2.1.0)
|
43
|
+
ruby2_keywords (>= 0.0.5)
|
44
|
+
mutex_m (0.1.2)
|
45
|
+
mysql2 (0.5.5)
|
34
46
|
rake (13.0.6)
|
35
47
|
retriable (3.1.2)
|
36
|
-
|
48
|
+
ruby2_keywords (0.0.5)
|
49
|
+
simplecov (0.22.0)
|
37
50
|
docile (~> 1.1)
|
38
51
|
simplecov-html (~> 0.11)
|
39
52
|
simplecov_json_formatter (~> 0.1)
|
40
53
|
simplecov-html (0.12.3)
|
41
|
-
simplecov_json_formatter (0.1.
|
42
|
-
thor (1.
|
43
|
-
|
44
|
-
|
54
|
+
simplecov_json_formatter (0.1.4)
|
55
|
+
thor (1.2.2)
|
56
|
+
timeout (0.4.0)
|
57
|
+
toxiproxy (2.0.2)
|
58
|
+
trilogy (2.6.0)
|
59
|
+
tzinfo (2.0.6)
|
45
60
|
concurrent-ruby (~> 1.0)
|
46
|
-
zeitwerk (2.5.1)
|
47
61
|
|
48
62
|
PLATFORMS
|
63
|
+
arm64-darwin-21
|
64
|
+
arm64-darwin-22
|
49
65
|
x86_64-darwin-20
|
50
66
|
x86_64-linux
|
51
67
|
|
@@ -61,6 +77,7 @@ DEPENDENCIES
|
|
61
77
|
rake
|
62
78
|
simplecov
|
63
79
|
toxiproxy
|
80
|
+
trilogy
|
64
81
|
|
65
82
|
BUNDLED WITH
|
66
83
|
2.2.22
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Tests](https://github.com/Shopify/lhm/actions/workflows/test.yml/badge.svg)](https://github.com/Shopify/lhm/actions/workflows/test.yml)
|
4
4
|
|
5
|
-
This is the Shopify fork of [SoundCloud's LHM](https://github.com/soundcloud/lhm). The
|
5
|
+
This is the Shopify fork of [SoundCloud's LHM](https://github.com/soundcloud/lhm). The
|
6
6
|
following description, originally from SoundCloud (with minor updates by Shopify),
|
7
7
|
gives some of the flavor around its original creation, and its choice of name...
|
8
8
|
|
@@ -57,7 +57,7 @@ a single integer numeric key column named `id`.
|
|
57
57
|
|
58
58
|
## Installation
|
59
59
|
|
60
|
-
Install it via `gem install lhm` or by adding `gem "lhm"` to your `Gemfile`.
|
60
|
+
Install it via `gem install lhm-shopify` or by adding `gem "lhm-shopify"` to your `Gemfile`.
|
61
61
|
|
62
62
|
## Usage
|
63
63
|
|
@@ -112,7 +112,7 @@ tables must be cleaned up.
|
|
112
112
|
### Usage with ProxySQL
|
113
113
|
LHM can recover from connection loss. However, when used in conjunction with ProxySQL, there are multiple ways that
|
114
114
|
connection loss could induce data loss (if triggered by a failover). Therefore it will perform additional checks to
|
115
|
-
ensure that the MySQL host stays consistent across the schema migrations if the feature is enabled.
|
115
|
+
ensure that the MySQL host stays consistent across the schema migrations if the feature is enabled.
|
116
116
|
This is done by tagging every query with `/*maintenance:lhm*/`, which will be recognized by ProxySQL.
|
117
117
|
However, to get this feature working, a new ProxySQL query rule must be added.
|
118
118
|
```cnf
|
@@ -127,7 +127,7 @@ However, to get this feature working, a new ProxySQL query rule must be added.
|
|
127
127
|
This will ensure that all relevant queries are forwarded to the current writer.
|
128
128
|
|
129
129
|
Also, ProxySQL disables [multiplexing](https://proxysql.com/documentation/multiplexing/) for `select` on `@@` variables.
|
130
|
-
Therefore, the following rules must be added to ensure that queries (even if tagged with `/*maintenance:lhm*/`) get
|
130
|
+
Therefore, the following rules must be added to ensure that queries (even if tagged with `/*maintenance:lhm*/`) get
|
131
131
|
forwarded to the right target.
|
132
132
|
```cnf
|
133
133
|
{
|
@@ -144,7 +144,7 @@ forwarded to the right target.
|
|
144
144
|
}
|
145
145
|
```
|
146
146
|
|
147
|
-
Once these changes are added to the ProxySQL configuration (either through `.cnf` or dynamically through the admin interface),
|
147
|
+
Once these changes are added to the ProxySQL configuration (either through `.cnf` or dynamically through the admin interface),
|
148
148
|
the feature can be enabled. This is done by adding this flag when providing options to the migration:
|
149
149
|
```ruby
|
150
150
|
Lhm.change_table(..., options: {reconnect_with_consistent_host: true}) do |t|
|
@@ -165,13 +165,13 @@ Lhm.change_table :users, throttler: my_throttler do |m|
|
|
165
165
|
end
|
166
166
|
```
|
167
167
|
|
168
|
-
###
|
168
|
+
### ReplicaLag Throttler
|
169
169
|
|
170
170
|
Lhm uses by default the time throttler, however a better solution is to throttle the copy of the data
|
171
|
-
depending on the time that the
|
171
|
+
depending on the time that the replicas are behind. To use the ReplicaLag throttler:
|
172
172
|
|
173
173
|
```ruby
|
174
|
-
Lhm.change_table :users, throttler: :
|
174
|
+
Lhm.change_table :users, throttler: :replica_lag_throttler do |m|
|
175
175
|
...
|
176
176
|
end
|
177
177
|
```
|
@@ -179,7 +179,7 @@ end
|
|
179
179
|
Or to set that as default throttler, use the following (for instance in a Rails initializer):
|
180
180
|
|
181
181
|
```ruby
|
182
|
-
Lhm.setup_throttler(:
|
182
|
+
Lhm.setup_throttler(:replica_lag_throttler)
|
183
183
|
```
|
184
184
|
|
185
185
|
### ThreadsRunning Throttler
|
@@ -189,6 +189,13 @@ throttle based on the number of threads running in MySQL, as a proxy for "is
|
|
189
189
|
this operation causing excessive load":
|
190
190
|
|
191
191
|
```ruby
|
192
|
+
my_throttler = Lhm::Throttler::ThreadsRunning.new(stride: 100_000)
|
193
|
+
|
194
|
+
Lhm.change_table :users, throttler: my_throttler do |m|
|
195
|
+
...
|
196
|
+
end
|
197
|
+
|
198
|
+
# or use default settings:
|
192
199
|
Lhm.change_table :users, throttler: :threads_running_throttler do |m|
|
193
200
|
...
|
194
201
|
end
|
@@ -278,7 +285,7 @@ To run the tests:
|
|
278
285
|
```bash
|
279
286
|
bundle exec rake unit # unit tests
|
280
287
|
bundle exec rake integration # integration tests
|
281
|
-
bundle exec rake
|
288
|
+
bundle exec rake specs # all tests
|
282
289
|
```
|
283
290
|
|
284
291
|
You can run an individual test as follows:
|
@@ -304,15 +311,15 @@ open coverage/index.html
|
|
304
311
|
```
|
305
312
|
|
306
313
|
### Merging for a new version
|
307
|
-
When creating a PR for a new version, make sure that th version has been bumped in `lib/lhm/version.rb`. Then run the following code snippet to ensure the everything is consistent, otherwise
|
314
|
+
When creating a PR for a new version, make sure that th version has been bumped in `lib/lhm/version.rb`. Then run the following code snippet to ensure the everything is consistent, otherwise
|
308
315
|
the gem will not publish.
|
309
316
|
```bash
|
310
317
|
bundle install
|
311
318
|
bundle update
|
312
|
-
bundle exec
|
319
|
+
bundle exec appraisal install
|
313
320
|
```
|
314
321
|
|
315
|
-
###
|
322
|
+
### Podman Compose
|
316
323
|
The integration tests rely on a replication configuration for MySQL which is being proxied by an instance of ProxySQL.
|
317
324
|
It is important that every container is running to execute the integration test suite.
|
318
325
|
|
@@ -327,7 +334,7 @@ The license is included as [LICENSE](LICENSE) in this directory.
|
|
327
334
|
* [Twitter][2]
|
328
335
|
* [pt-online-schema-change][3]
|
329
336
|
|
330
|
-
[0]:
|
337
|
+
[0]: https://shlomi-noach.github.io/openarkkit/introduction.html
|
331
338
|
[1]: http://www.facebook.com/note.php?note\_id=430801045932
|
332
339
|
[2]: https://github.com/freels/table_migrator
|
333
340
|
[3]: http://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-change.html
|
data/dev.yml
CHANGED
@@ -5,17 +5,17 @@ up:
|
|
5
5
|
or: [mysql@5.7]
|
6
6
|
conflicts: [shopify/shopify/mysql-client, mysql-connector-c, mysql, mysql-client]
|
7
7
|
- wget
|
8
|
-
- ruby: 2.
|
8
|
+
- ruby: 3.2.2
|
9
9
|
- bundler
|
10
|
+
- podman
|
10
11
|
- custom:
|
11
12
|
name: Get Appraisal gems
|
12
13
|
met?: bundle exec appraisal install
|
13
14
|
meet: ":"
|
14
|
-
- docker
|
15
15
|
- custom:
|
16
|
-
name:
|
17
|
-
met?:
|
18
|
-
meet:
|
16
|
+
name: Podman compose
|
17
|
+
met?: podman-compose ps | grep -ioE -q "lhm.*running\(4\)"
|
18
|
+
meet: podman-compose up -d
|
19
19
|
- custom:
|
20
20
|
name: Waiting for DBs to be operational
|
21
21
|
met?: ./scripts/helpers/wait-for-dbs.sh
|
@@ -25,7 +25,8 @@ commands:
|
|
25
25
|
unit: bundle exec rake unit
|
26
26
|
int: bundle exec rake integration
|
27
27
|
test:
|
28
|
-
|
28
|
+
syntax:
|
29
|
+
optional: file
|
29
30
|
aliases: [ t ]
|
30
31
|
run: |
|
31
32
|
if [[ $# -eq 0 ]]; then
|
@@ -37,9 +38,12 @@ commands:
|
|
37
38
|
cov: rm -rf coverage; COV=1 bundle exec rake unit && bundle exec rake integration; open coverage/index.html
|
38
39
|
logs:
|
39
40
|
desc: "See the DB logs (ctrl-c + ctrl-c to exit)"
|
40
|
-
run:
|
41
|
+
run: podman-compose logs -f
|
41
42
|
clear:
|
42
|
-
run:
|
43
|
+
run: podman-compose down -v && podman-compose up -d && ./scripts/helpers/wait-for-dbs.sh
|
44
|
+
subcommands:
|
45
|
+
mysql-5.7: podman-compose down -v && podman-compose -f docker-compose-mysql-5.7.yml up -d && ./scripts/helpers/wait-for-dbs.sh
|
46
|
+
mysql-8.0: podman-compose down -v && podman-compose -f docker-compose-mysql-8.0.yml up -d && ./scripts/helpers/wait-for-dbs.sh
|
43
47
|
pre-publish:
|
44
48
|
# Ensures all Gemfile.lock are sync with the new version in `lhm/version.rb` and runs appraisals
|
45
49
|
run: bundle install && bundle exec appraisal install && bundle exec appraisal rake specs
|
@@ -0,0 +1 @@
|
|
1
|
+
docker-compose.yml
|
@@ -0,0 +1,63 @@
|
|
1
|
+
services:
|
2
|
+
# Writer
|
3
|
+
mysql-1:
|
4
|
+
container_name: mysql-1
|
5
|
+
image: percona:8.0
|
6
|
+
platform: linux/amd64
|
7
|
+
command:
|
8
|
+
--server-id=1
|
9
|
+
--log-bin
|
10
|
+
--log-slave-updates=ON
|
11
|
+
--gtid-mode=ON
|
12
|
+
--enforce-gtid-consistency=ON
|
13
|
+
--read-only=OFF
|
14
|
+
--max-connections=1000
|
15
|
+
--default-authentication-plugin=mysql_native_password
|
16
|
+
hostname: 'mysql-1'
|
17
|
+
volumes:
|
18
|
+
- ./scripts/mysql/writer:/docker-entrypoint-initdb.d
|
19
|
+
environment:
|
20
|
+
MYSQL_ROOT_PASSWORD: password
|
21
|
+
MYSQL_HOST: mysql-1
|
22
|
+
ports:
|
23
|
+
- "13006:3306"
|
24
|
+
# Reader
|
25
|
+
mysql-2:
|
26
|
+
container_name: mysql-2
|
27
|
+
image: percona:8.0
|
28
|
+
platform: linux/amd64
|
29
|
+
command:
|
30
|
+
--server-id=2
|
31
|
+
--log-bin
|
32
|
+
--log-slave-updates=ON
|
33
|
+
--gtid-mode=ON
|
34
|
+
--enforce-gtid-consistency=ON
|
35
|
+
--read-only=ON
|
36
|
+
--max-connections=1000
|
37
|
+
--default-authentication-plugin=mysql_native_password
|
38
|
+
hostname: 'mysql-2'
|
39
|
+
volumes:
|
40
|
+
- ./scripts/mysql/reader:/docker-entrypoint-initdb.d
|
41
|
+
environment:
|
42
|
+
MYSQL_ROOT_PASSWORD: password
|
43
|
+
MYSQL_HOST: mysql-2
|
44
|
+
ports:
|
45
|
+
- "13007:3306"
|
46
|
+
# Proxysql
|
47
|
+
proxysql:
|
48
|
+
container_name: proxysql
|
49
|
+
image: proxysql/proxysql:2.0.11
|
50
|
+
platform: linux/amd64
|
51
|
+
volumes:
|
52
|
+
- ./scripts/proxysql/proxysql.cnf:/etc/proxysql.cnf
|
53
|
+
command: "proxysql -c /etc/proxysql.cnf -f --idle-threads"
|
54
|
+
ports:
|
55
|
+
- "13005:3306"
|
56
|
+
- "6032:6032"
|
57
|
+
toxiproxy:
|
58
|
+
container_name: toxiproxy
|
59
|
+
image: "ghcr.io/shopify/toxiproxy"
|
60
|
+
ports:
|
61
|
+
- "8474:8474"
|
62
|
+
- "22220:22220"
|
63
|
+
- "22222:22222"
|
data/docker-compose.yml
CHANGED
@@ -3,6 +3,7 @@ services:
|
|
3
3
|
mysql-1:
|
4
4
|
container_name: mysql-1
|
5
5
|
image: percona:5.7
|
6
|
+
platform: linux/amd64
|
6
7
|
command:
|
7
8
|
--server-id=1
|
8
9
|
--log-bin
|
@@ -18,11 +19,12 @@ services:
|
|
18
19
|
MYSQL_ROOT_PASSWORD: password
|
19
20
|
MYSQL_HOST: mysql-1
|
20
21
|
ports:
|
21
|
-
- "
|
22
|
+
- "13006:3306"
|
22
23
|
# Reader
|
23
24
|
mysql-2:
|
24
25
|
container_name: mysql-2
|
25
26
|
image: percona:5.7
|
27
|
+
platform: linux/amd64
|
26
28
|
command:
|
27
29
|
--server-id=2
|
28
30
|
--log-bin
|
@@ -38,7 +40,7 @@ services:
|
|
38
40
|
MYSQL_ROOT_PASSWORD: password
|
39
41
|
MYSQL_HOST: mysql-2
|
40
42
|
ports:
|
41
|
-
- "
|
43
|
+
- "13007:3306"
|
42
44
|
# Proxysql
|
43
45
|
proxysql:
|
44
46
|
container_name: proxysql
|
@@ -47,7 +49,7 @@ services:
|
|
47
49
|
- ./scripts/proxysql/proxysql.cnf:/etc/proxysql.cnf
|
48
50
|
command: "proxysql -c /etc/proxysql.cnf -f --idle-threads"
|
49
51
|
ports:
|
50
|
-
- "
|
52
|
+
- "13005:3306"
|
51
53
|
- "6032:6032"
|
52
54
|
toxiproxy:
|
53
55
|
container_name: toxiproxy
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
lhm-shopify (
|
4
|
+
lhm-shopify (4.1.0)
|
5
5
|
retriable (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -12,6 +12,9 @@ GEM
|
|
12
12
|
activerecord (6.1.0)
|
13
13
|
activemodel (= 6.1.0)
|
14
14
|
activesupport (= 6.1.0)
|
15
|
+
activerecord-trilogy-adapter (3.1.2)
|
16
|
+
activerecord (>= 6.0.a, < 7.1.a)
|
17
|
+
trilogy (>= 2.4.0)
|
15
18
|
activesupport (6.1.0)
|
16
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
20
|
i18n (>= 1.6, < 2)
|
@@ -19,38 +22,44 @@ GEM
|
|
19
22
|
tzinfo (~> 2.0)
|
20
23
|
zeitwerk (~> 2.3)
|
21
24
|
after_do (0.4.0)
|
22
|
-
appraisal (2.
|
25
|
+
appraisal (2.5.0)
|
23
26
|
bundler
|
24
27
|
rake
|
25
28
|
thor (>= 0.14.0)
|
26
29
|
byebug (11.1.3)
|
27
|
-
concurrent-ruby (1.
|
30
|
+
concurrent-ruby (1.2.2)
|
28
31
|
docile (1.4.0)
|
29
|
-
i18n (1.
|
32
|
+
i18n (1.14.1)
|
30
33
|
concurrent-ruby (~> 1.0)
|
31
|
-
minitest (5.
|
32
|
-
mocha (1.
|
33
|
-
|
34
|
+
minitest (5.20.0)
|
35
|
+
mocha (2.1.0)
|
36
|
+
ruby2_keywords (>= 0.0.5)
|
37
|
+
mysql2 (0.5.5)
|
34
38
|
rake (13.0.6)
|
35
39
|
retriable (3.1.2)
|
36
|
-
|
40
|
+
ruby2_keywords (0.0.5)
|
41
|
+
simplecov (0.22.0)
|
37
42
|
docile (~> 1.1)
|
38
43
|
simplecov-html (~> 0.11)
|
39
44
|
simplecov_json_formatter (~> 0.1)
|
40
45
|
simplecov-html (0.12.3)
|
41
|
-
simplecov_json_formatter (0.1.
|
42
|
-
thor (1.
|
43
|
-
toxiproxy (2.0.
|
44
|
-
|
46
|
+
simplecov_json_formatter (0.1.4)
|
47
|
+
thor (1.2.2)
|
48
|
+
toxiproxy (2.0.2)
|
49
|
+
trilogy (2.6.0)
|
50
|
+
tzinfo (2.0.6)
|
45
51
|
concurrent-ruby (~> 1.0)
|
46
|
-
zeitwerk (2.
|
52
|
+
zeitwerk (2.6.12)
|
47
53
|
|
48
54
|
PLATFORMS
|
55
|
+
arm64-darwin-21
|
56
|
+
arm64-darwin-22
|
49
57
|
x86_64-darwin-20
|
50
58
|
x86_64-linux
|
51
59
|
|
52
60
|
DEPENDENCIES
|
53
61
|
activerecord (= 6.1.0)
|
62
|
+
activerecord-trilogy-adapter
|
54
63
|
after_do
|
55
64
|
appraisal
|
56
65
|
byebug
|
@@ -61,6 +70,7 @@ DEPENDENCIES
|
|
61
70
|
rake
|
62
71
|
simplecov
|
63
72
|
toxiproxy
|
73
|
+
trilogy
|
64
74
|
|
65
75
|
BUNDLED WITH
|
66
76
|
2.2.22
|