pg_easy_replicate 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/pg_easy_replicate/cli.rb +2 -2
- data/lib/pg_easy_replicate/orchestrate.rb +11 -6
- data/lib/pg_easy_replicate/version.rb +1 -1
- data/scripts/e2e-bootstrap.sh +19 -0
- data/scripts/e2e-start.sh +18 -0
- data/{bin → scripts}/release.sh +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba133c0e80239fb125f32daa490fd20efe18c3f7391291d8465a8688fb3c0caf
|
4
|
+
data.tar.gz: f5c1780f43b621ddf4a8359d7dd3131291f42fe064cbd131b1b49308f0bc041e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1d9e43d36d98b1cfe1e992123783f3adb160851acbc60447b77b7fba244dfbb1bf219686759b93619a9ac682813a24449bd4ddb3fea5c09f9990f6276b04ca9
|
7
|
+
data.tar.gz: 68d31a389a1ff11a5e30bbe48b6ab9ebd746adf2a2787c18388627e08c8cd8c2dbaa289e1f898ab2a119b7da2a3e72df92a88a6826504c2438fa6a1cd6e7348e
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [0.1.5] - 2023-06-22
|
2
|
+
|
3
|
+
- Fix bug in `stop_sync`
|
4
|
+
|
5
|
+
## [0.1.4] - 2023-06-22
|
6
|
+
|
7
|
+
- Drop lockbox dependency
|
8
|
+
- Support password with special chars and test for url encoded URI
|
9
|
+
- Support AWS and GCP special user scenarios and introduce `--special-user-role`
|
10
|
+
|
11
|
+
## [0.1.3] - 2023-06-22
|
12
|
+
|
13
|
+
- Docker multi-platform image build support for linux/amd64 and linux/arm64 starting 0.1.3
|
14
|
+
|
1
15
|
## [0.1.2] - 2023-06-22
|
2
16
|
|
3
17
|
- Keep the internal username unique
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ Battle tested in production at [Tines](https://www.tines.com/) 🚀
|
|
15
15
|
- [Replicating all tables with a single group](#replicating-all-tables-with-a-single-group)
|
16
16
|
- [Config check](#config-check)
|
17
17
|
- [Bootstrap](#bootstrap)
|
18
|
-
- [Bootstrap and Config Check with special user role
|
18
|
+
- [Bootstrap and Config Check with special user role in AWS or GCP](#bootstrap-and-config-check-with-special-user-role-in-aws-or-gcp)
|
19
19
|
- [Config Check](#config-check)
|
20
20
|
- [Bootstrap](#bootstrap-1)
|
21
21
|
- [Start sync](#start-sync)
|
@@ -120,7 +120,7 @@ $ pg_easy_replicate bootstrap --group-name database-cluster-1
|
|
120
120
|
...
|
121
121
|
```
|
122
122
|
|
123
|
-
### Bootstrap and Config Check with special user role
|
123
|
+
### Bootstrap and Config Check with special user role in AWS or GCP
|
124
124
|
|
125
125
|
If you don't want your primary login user to have `superuser` privileges or you are on AWS or GCP, you will need to pass in the special user role that has the privileges to create role, schema, publication and subscription. This is required so `pg_easy_replicate` can create a dedicated user for replication which is granted the respective special user role to carry out its functionalities.
|
126
126
|
|
@@ -12,7 +12,7 @@ module PgEasyReplicate
|
|
12
12
|
aliases: "-s",
|
13
13
|
desc:
|
14
14
|
"Name of the role that has superuser permissions. Usually useful for AWS (rds_superuser) or GCP (cloudsqlsuperuser)."
|
15
|
-
def config_check
|
15
|
+
def config_check
|
16
16
|
PgEasyReplicate.assert_config(
|
17
17
|
special_user_role: options[:special_user_role],
|
18
18
|
)
|
@@ -81,7 +81,7 @@ module PgEasyReplicate
|
|
81
81
|
required: true,
|
82
82
|
desc: "Name of the group previously provisioned"
|
83
83
|
def stop_sync
|
84
|
-
PgEasyReplicate::Orchestrate.stop_sync(options[:group_name])
|
84
|
+
PgEasyReplicate::Orchestrate.stop_sync(group_name: options[:group_name])
|
85
85
|
end
|
86
86
|
|
87
87
|
desc "switchover ",
|
@@ -18,7 +18,7 @@ module PgEasyReplicate
|
|
18
18
|
group_name: options[:group_name],
|
19
19
|
tables: options[:tables],
|
20
20
|
conn_string: source_db_url,
|
21
|
-
schema: options[:
|
21
|
+
schema: options[:schema_name],
|
22
22
|
)
|
23
23
|
|
24
24
|
create_subscription(
|
@@ -30,7 +30,7 @@ module PgEasyReplicate
|
|
30
30
|
Group.create(
|
31
31
|
name: options[:group_name],
|
32
32
|
table_names: options[:tables],
|
33
|
-
schema_name: options[:
|
33
|
+
schema_name: options[:schema_name],
|
34
34
|
started_at: Time.now.utc,
|
35
35
|
)
|
36
36
|
rescue => e
|
@@ -46,7 +46,7 @@ module PgEasyReplicate
|
|
46
46
|
Group.create(
|
47
47
|
name: options[:group_name],
|
48
48
|
table_names: options[:tables],
|
49
|
-
schema_name: options[:
|
49
|
+
schema_name: options[:schema_name],
|
50
50
|
started_at: Time.now.utc,
|
51
51
|
failed_at: Time.now.utc,
|
52
52
|
)
|
@@ -80,6 +80,7 @@ module PgEasyReplicate
|
|
80
80
|
"Adding tables up publication",
|
81
81
|
{ publication_name: publication_name(group_name) },
|
82
82
|
)
|
83
|
+
|
83
84
|
tables = tables&.split(",") || []
|
84
85
|
unless tables.size > 0
|
85
86
|
tables = list_all_tables(schema: schema, conn_string: conn_string)
|
@@ -169,7 +170,11 @@ module PgEasyReplicate
|
|
169
170
|
raise "Unable to drop subscription: #{e.message}"
|
170
171
|
end
|
171
172
|
|
172
|
-
def stop_sync(
|
173
|
+
def stop_sync(
|
174
|
+
group_name:,
|
175
|
+
source_conn_string: source_db_url,
|
176
|
+
target_conn_string: target_db_url
|
177
|
+
)
|
173
178
|
logger.info(
|
174
179
|
"Stopping sync",
|
175
180
|
{
|
@@ -193,11 +198,11 @@ module PgEasyReplicate
|
|
193
198
|
group_name:,
|
194
199
|
source_conn_string: source_db_url,
|
195
200
|
target_conn_string: target_db_url,
|
196
|
-
lag_delta_size:
|
201
|
+
lag_delta_size: nil
|
197
202
|
)
|
198
203
|
group = Group.find(group_name)
|
199
204
|
|
200
|
-
watch_lag(group_name: group_name, lag: lag_delta_size)
|
205
|
+
watch_lag(group_name: group_name, lag: lag_delta_size || DEFAULT_LAG)
|
201
206
|
revoke_connections_on_source_db(group_name)
|
202
207
|
wait_for_remaining_catchup(group_name)
|
203
208
|
refresh_sequences(
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -eo pipefail
|
4
|
+
|
5
|
+
if [[ -z ${GITHUB_WORKFLOW} ]]; then
|
6
|
+
export SECONDARY_SOURCE_DB_URL="postgres://jamesbond:jamesbond123%407%21%273aaR@source_db/postgres"
|
7
|
+
fi
|
8
|
+
|
9
|
+
export SOURCE_DB_URL="postgres://jamesbond:jamesbond123%407%21%273aaR@localhost:5432/postgres"
|
10
|
+
export TARGET_DB_URL="postgres://jamesbond:jamesbond123%407%21%273aaR@localhost:5433/postgres"
|
11
|
+
export PGPASSWORD='jamesbond123@7!'"'"'3aaR'
|
12
|
+
|
13
|
+
pgbench --initialize -s 5 --foreign-keys --host localhost -U jamesbond -d postgres
|
14
|
+
|
15
|
+
pg_dump --schema-only --host localhost -U jamesbond -d postgres >schema.sql
|
16
|
+
cat schema.sql | psql --host localhost -U jamesbond -d postgres -p 5433
|
17
|
+
rm schema.sql
|
18
|
+
|
19
|
+
bundle exec bin/pg_easy_replicate config_check
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -eo pipefail
|
4
|
+
|
5
|
+
if [[ -z ${GITHUB_WORKFLOW} ]]; then
|
6
|
+
export SECONDARY_SOURCE_DB_URL="postgres://jamesbond:jamesbond123%407%21%273aaR@source_db/postgres"
|
7
|
+
fi
|
8
|
+
|
9
|
+
export SOURCE_DB_URL="postgres://jamesbond:jamesbond123%407%21%273aaR@localhost:5432/postgres"
|
10
|
+
export TARGET_DB_URL="postgres://jamesbond:jamesbond123%407%21%273aaR@localhost:5433/postgres"
|
11
|
+
export PGPASSWORD='jamesbond123@7!'"'"''"'"'3aaR'
|
12
|
+
|
13
|
+
# Bootstrap and cleanup
|
14
|
+
echo "===== Performing Bootstrap and cleanup"
|
15
|
+
bundle exec bin/pg_easy_replicate bootstrap -g cluster-1
|
16
|
+
bundle exec bin/pg_easy_replicate start_sync -g cluster-1 -s public
|
17
|
+
bundle exec bin/pg_easy_replicate stats -g cluster-1
|
18
|
+
bundle exec bin/pg_easy_replicate switchover -g cluster-1
|
data/{bin → scripts}/release.sh
RENAMED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shayon Mukherjee
|
@@ -241,7 +241,6 @@ email:
|
|
241
241
|
executables:
|
242
242
|
- pg_easy_replicate
|
243
243
|
- pg_easy_replicate_console
|
244
|
-
- release.sh
|
245
244
|
extensions: []
|
246
245
|
extra_rdoc_files: []
|
247
246
|
files:
|
@@ -259,7 +258,6 @@ files:
|
|
259
258
|
- Rakefile
|
260
259
|
- bin/pg_easy_replicate
|
261
260
|
- bin/pg_easy_replicate_console
|
262
|
-
- bin/release.sh
|
263
261
|
- docker-compose.yml
|
264
262
|
- lib/pg_easy_replicate.rb
|
265
263
|
- lib/pg_easy_replicate/cli.rb
|
@@ -270,6 +268,9 @@ files:
|
|
270
268
|
- lib/pg_easy_replicate/stats.rb
|
271
269
|
- lib/pg_easy_replicate/version.rb
|
272
270
|
- package.json
|
271
|
+
- scripts/e2e-bootstrap.sh
|
272
|
+
- scripts/e2e-start.sh
|
273
|
+
- scripts/release.sh
|
273
274
|
- yarn.lock
|
274
275
|
homepage: https://github.com/shayonj/pg_easy_replicate
|
275
276
|
licenses:
|