pg_easy_replicate 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Dockerfile +1 -1
- data/Gemfile.lock +8 -6
- data/README.md +9 -4
- data/bin/release.sh +7 -7
- data/lib/pg_easy_replicate/cli.rb +1 -1
- data/lib/pg_easy_replicate/helper.rb +1 -1
- data/lib/pg_easy_replicate/version.rb +1 -1
- metadata +4 -6
- data/bin/setup +0 -8
- /data/bin/{console → pg_easy_replicate_console} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5df08d2cfc5874389ab9a5311a572a39ea76e5c2a56a53df3db935865caeb99
|
4
|
+
data.tar.gz: 156656c80d4d808bc1a623507e0a2da904f9c7ebd26ec9e767382aac90276d70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47e224f6e9d1133f5a2eee992e42afddefdf89f908dc763c84d4e36547849f3e69824f47481df05d2552d7708240af75aa32f056e2cacf60293fdefe983fc2ed
|
7
|
+
data.tar.gz: '0184bfa3eafd4224cc5eefa32f45fead0491e507e7df78e0395a06dd9ce22bd4b76ea59e4d253113e0fc3dbdbb73b548175d44f87a4acf070633657629310568'
|
data/CHANGELOG.md
CHANGED
data/Dockerfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pg_easy_replicate (0.1.
|
4
|
+
pg_easy_replicate (0.1.2)
|
5
5
|
lockbox (~> 1.2.0)
|
6
6
|
ougai (~> 2.0.0)
|
7
7
|
pg (~> 1.5.3)
|
@@ -25,17 +25,19 @@ GEM
|
|
25
25
|
ougai (2.0.0)
|
26
26
|
oj (~> 3.10)
|
27
27
|
parallel (1.23.0)
|
28
|
-
parser (3.2.2.
|
28
|
+
parser (3.2.2.3)
|
29
29
|
ast (~> 2.4.1)
|
30
|
+
racc
|
30
31
|
pg (1.5.3)
|
31
32
|
prettier_print (1.2.1)
|
32
33
|
pry (0.14.2)
|
33
34
|
coderay (~> 1.1)
|
34
35
|
method_source (~> 1.0)
|
36
|
+
racc (1.7.1)
|
35
37
|
rainbow (3.1.1)
|
36
38
|
rake (13.0.6)
|
37
39
|
rbs (3.1.0)
|
38
|
-
regexp_parser (2.8.
|
40
|
+
regexp_parser (2.8.1)
|
39
41
|
rexml (3.2.5)
|
40
42
|
rspec (3.12.0)
|
41
43
|
rspec-core (~> 3.12.0)
|
@@ -50,17 +52,17 @@ GEM
|
|
50
52
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
53
|
rspec-support (~> 3.12.0)
|
52
54
|
rspec-support (3.12.0)
|
53
|
-
rubocop (1.
|
55
|
+
rubocop (1.52.1)
|
54
56
|
json (~> 2.3)
|
55
57
|
parallel (~> 1.10)
|
56
|
-
parser (>= 3.2.
|
58
|
+
parser (>= 3.2.2.3)
|
57
59
|
rainbow (>= 2.2.2, < 4.0)
|
58
60
|
regexp_parser (>= 1.8, < 3.0)
|
59
61
|
rexml (>= 3.2.5, < 4.0)
|
60
62
|
rubocop-ast (>= 1.28.0, < 2.0)
|
61
63
|
ruby-progressbar (~> 1.7)
|
62
64
|
unicode-display_width (>= 2.4.0, < 3.0)
|
63
|
-
rubocop-ast (1.
|
65
|
+
rubocop-ast (1.29.0)
|
64
66
|
parser (>= 3.2.1.0)
|
65
67
|
rubocop-capybara (2.18.0)
|
66
68
|
rubocop (~> 1.41)
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# pg_easy_replicate
|
2
2
|
|
3
|
-
|
3
|
+
[![CI](https://github.com/shayonj/pg_easy_replicate/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/shayonj/pg_easy_replicate/actions/workflows/ci.yaml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/pg_easy_replicate.svg)](https://badge.fury.io/rb/pg_easy_replicate)
|
5
|
+
|
6
|
+
`pg_easy_replicate` is a CLI orchestrator tool that simplifies the process of setting up [logical replication](https://www.postgresql.org/docs/current/logical-replication.html) between two PostgreSQL databases. `pg_easy_replicate` also supports switchover. After the source (primary database) is fully replicating, `pg_easy_replicate` puts it into read-only mode and via logical replication flushes all data to the new target database. This ensures zero data loss and minimal downtime for the application. This method can be useful for performing minimal downtime (up to <1min, depending) major version upgrades between two PostgreSQL databases, load testing with blue/green database setup and other similar use cases.
|
7
|
+
|
8
|
+
Battle tested in production at [Tines](https://www.tines.com/) 🚀
|
4
9
|
|
5
10
|
- [Installation](#installation)
|
6
11
|
- [Requirements](#requirements)
|
@@ -65,9 +70,9 @@ $ export TARGET_DB_URL="postgres://USERNAME:PASSWORD@localhost:5433/DATABASE_NAM
|
|
65
70
|
Any `pg_easy_replicate` command can be run the same way with the docker image as well. As long the container is running in an environment where it has access to both the databases. Example
|
66
71
|
|
67
72
|
```bash
|
68
|
-
docker run -
|
69
|
-
-e SOURCE_DB_URL="postgres://USERNAME:PASSWORD@localhost:5432/DATABASE_NAME" \
|
73
|
+
docker run -e SOURCE_DB_URL="postgres://USERNAME:PASSWORD@localhost:5432/DATABASE_NAME" \
|
70
74
|
-e TARGET_DB_URL="postgres://USERNAME:PASSWORD@localhost:5433/DATABASE_NAME" \
|
75
|
+
-it --rm shayonj/pg_easy_replicate:latest \
|
71
76
|
pg_easy_replicate config_check
|
72
77
|
```
|
73
78
|
|
@@ -210,4 +215,4 @@ Next, you can set up a program that watches the `stats` and waits until `switcho
|
|
210
215
|
|
211
216
|
In this strategy, you have a weighted based DNS system (example [AWS Route53 weighted records](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-weighted.html)) where 100% of traffic goes to a primary origin and 0% to a secondary origin. The primary origin here is the DNS host for your source database and secondary origin is the DNS host for your target database. You can set up your application ahead of time to interact with the database using DNS from the weighted group.
|
212
217
|
|
213
|
-
Next, you can set up a program that watches the `stats` and waits until `switchover_completed_at` is reporting as `true`. Once that happens it updates the weight in the DNS weighted group where 100% of the requests now go to the new/target database. Note: Keeping a
|
218
|
+
Next, you can set up a program that watches the `stats` and waits until `switchover_completed_at` is reporting as `true`. Once that happens it updates the weight in the DNS weighted group where 100% of the requests now go to the new/target database. Note: Keeping a low `ttl` is recommended.
|
data/bin/release.sh
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
export VERSION=$1
|
2
2
|
echo "VERSION: ${VERSION}"
|
3
3
|
|
4
|
-
echo "=== Pushing tags to github ===="
|
5
|
-
git tag v"$VERSION"
|
6
|
-
git push origin --tags
|
4
|
+
# echo "=== Pushing tags to github ===="
|
5
|
+
# git tag v"$VERSION"
|
6
|
+
# git push origin --tags
|
7
7
|
|
8
8
|
echo "=== Building Gem ===="
|
9
9
|
gem build pg_easy_replicate.gemspec
|
@@ -15,14 +15,14 @@ echo "=== Sleeping for 5s ===="
|
|
15
15
|
sleep 5
|
16
16
|
|
17
17
|
echo "=== Building Image ===="
|
18
|
-
docker build . --build-arg VERSION="$VERSION" -t shayonj/
|
18
|
+
docker build . --build-arg VERSION="$VERSION" -t shayonj/pg_easy_replicate:"$VERSION"
|
19
19
|
|
20
20
|
echo "=== Tagging Image ===="
|
21
|
-
docker image tag shayonj/
|
21
|
+
docker image tag shayonj/pg_easy_replicate:"$VERSION" shayonj/pg_easy_replicate:latest
|
22
22
|
|
23
23
|
echo "=== Pushing Image ===="
|
24
|
-
docker push shayonj/
|
25
|
-
docker push shayonj/
|
24
|
+
docker push shayonj/pg_easy_replicate:"$VERSION"
|
25
|
+
docker push shayonj/pg_easy_replicate:latest
|
26
26
|
|
27
27
|
echo "=== Cleaning up ===="
|
28
28
|
rm pg_easy_replicate-"$VERSION".gem
|
@@ -55,7 +55,7 @@ module PgEasyReplicate
|
|
55
55
|
method_option :schema_name,
|
56
56
|
aliases: "-s",
|
57
57
|
desc:
|
58
|
-
"Name of the schema tables are in, only required if
|
58
|
+
"Name of the schema tables are in, only required if passing list of tables"
|
59
59
|
method_option :tables,
|
60
60
|
aliases: "-t",
|
61
61
|
desc:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_easy_replicate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shayon Mukherjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lockbox
|
@@ -253,10 +253,9 @@ description: Easily setup logical replication and switchover to new database wit
|
|
253
253
|
email:
|
254
254
|
- shayonj@gmail.com
|
255
255
|
executables:
|
256
|
-
- console
|
257
256
|
- pg_easy_replicate
|
257
|
+
- pg_easy_replicate_console
|
258
258
|
- release.sh
|
259
|
-
- setup
|
260
259
|
extensions: []
|
261
260
|
extra_rdoc_files: []
|
262
261
|
files:
|
@@ -272,10 +271,9 @@ files:
|
|
272
271
|
- LICENSE.txt
|
273
272
|
- README.md
|
274
273
|
- Rakefile
|
275
|
-
- bin/console
|
276
274
|
- bin/pg_easy_replicate
|
275
|
+
- bin/pg_easy_replicate_console
|
277
276
|
- bin/release.sh
|
278
|
-
- bin/setup
|
279
277
|
- docker-compose.yml
|
280
278
|
- lib/pg_easy_replicate.rb
|
281
279
|
- lib/pg_easy_replicate/cli.rb
|
data/bin/setup
DELETED
File without changes
|