pg_online_schema_change 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/pg_online_schema_change/orchestrate.rb +4 -2
- data/lib/pg_online_schema_change/replay.rb +4 -4
- data/lib/pg_online_schema_change/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: 3bc78403dc036598371393d5be0914bd7150660eda9798fb827af2892d058396
|
4
|
+
data.tar.gz: 6dbfb6e41267accf02e0da8ba88d7ea5039aa368ddc497e40d81f8952bed811d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0683dd33e681162a1b16b471fbefc52021b66ccbb3235994fd0654c6d97052a5482e22e29c1280cbc332eb8510b1b4a571075b4e36f9a2565c359ad086100d05'
|
7
|
+
data.tar.gz: 51e1fcd9d8d8d4f2a3f5760dee1e51fbde5a45f3bf7dd9c2d048390856b3b71bfb23333b053e0a0e43c026e90a9f704efbc903760cd37e95eb5ac5ea24b66512
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [0.5.0] - 2022-02-26
|
2
|
+
* Share some preliminary load test figures in https://github.com/shayonj/pg-osc/pull/54
|
3
|
+
* Reuse existing transaction open for reading table columns in https://github.com/shayonj/pg-osc/pull/53
|
4
|
+
* Start to deprecate --password with PGPASSWORD in https://github.com/shayonj/pg-osc/pull/56
|
5
|
+
* Introduce configurable PULL_BATCH_COUNT and DELTA_COUNT in https://github.com/shayonj/pg-osc/pull/57
|
6
|
+
|
1
7
|
## [0.4.0] - 2022-02-22
|
2
8
|
* Lint sourcecode, setup Rubocop proper and Lint in CI by @shayonj in https://github.com/shayonj/pg-osc/pull/46
|
3
9
|
* Uniquely identify operation_type column by @shayonj in https://github.com/shayonj/pg-osc/pull/50
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when
|
|
39
39
|
|
40
40
|
## Enforcement
|
41
41
|
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at shayonj@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
43
|
|
44
44
|
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
45
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -100,6 +100,7 @@ print the version
|
|
100
100
|
- `pg-osc` acquires minimal locks throughout the process (read more below on the caveats).
|
101
101
|
- Copies over indexes and Foreign keys.
|
102
102
|
- Optionally drop or retain old tables in the end.
|
103
|
+
- Tune how slow or fast should replays be from the audit/log table ([Replaying larger workloads](#replaying-larger-workloads)).
|
103
104
|
- Backfill old/new columns as data is copied from primary table to shadow table, and then perform the swap. [Example](#backfill-data)
|
104
105
|
- **TBD**: Ability to reverse the change with no data loss. [tracking issue](https://github.com/shayonj/pg-osc/issues/14)
|
105
106
|
|
@@ -37,6 +37,8 @@ module PgOnlineSchemaChange
|
|
37
37
|
Store.set(:audit_table_pk, "at_#{pgosc_identifier}_id")
|
38
38
|
Store.set(:audit_table_pk_sequence, "#{audit_table}_#{audit_table_pk}_seq")
|
39
39
|
Store.set(:shadow_table, "pgosc_st_#{client.table}_#{pgosc_identifier}")
|
40
|
+
|
41
|
+
Store.set(:foreign_key_statements, Query.get_foreign_keys_to_refresh(client, client.table))
|
40
42
|
end
|
41
43
|
|
42
44
|
def run!(options)
|
@@ -221,7 +223,6 @@ module PgOnlineSchemaChange
|
|
221
223
|
def swap!
|
222
224
|
logger.info("Performing swap!")
|
223
225
|
|
224
|
-
foreign_key_statements = Query.get_foreign_keys_to_refresh(client, client.table)
|
225
226
|
storage_params_reset = primary_table_storage_parameters.empty? ? "" : "ALTER TABLE #{client.table} SET (#{primary_table_storage_parameters});"
|
226
227
|
|
227
228
|
# From here on, all statements are carried out in a single
|
@@ -244,7 +245,7 @@ module PgOnlineSchemaChange
|
|
244
245
|
DROP TRIGGER IF EXISTS primary_to_audit_table_trigger ON #{client.table};
|
245
246
|
SQL
|
246
247
|
|
247
|
-
Query.run(client.connection, sql)
|
248
|
+
Query.run(client.connection, sql, opened)
|
248
249
|
ensure
|
249
250
|
Query.run(client.connection, "COMMIT;")
|
250
251
|
Query.run(client.connection, "SET statement_timeout = 0;")
|
@@ -270,6 +271,7 @@ module PgOnlineSchemaChange
|
|
270
271
|
shadow_table_drop = shadow_table ? "DROP TABLE IF EXISTS #{shadow_table}" : ""
|
271
272
|
|
272
273
|
sql = <<~SQL
|
274
|
+
DROP TRIGGER IF EXISTS primary_to_audit_table_trigger ON #{client.table};
|
273
275
|
#{audit_table_drop};
|
274
276
|
#{shadow_table_drop};
|
275
277
|
#{primary_drop}
|
@@ -87,7 +87,7 @@ module PgOnlineSchemaChange
|
|
87
87
|
SQL
|
88
88
|
to_be_replayed << sql
|
89
89
|
|
90
|
-
to_be_deleted_rows << "'#{row[
|
90
|
+
to_be_deleted_rows << "'#{row[audit_table_pk]}'"
|
91
91
|
when "UPDATE"
|
92
92
|
set_values = new_row.map do |column, value|
|
93
93
|
"#{column} = '#{value}'"
|
@@ -100,14 +100,14 @@ module PgOnlineSchemaChange
|
|
100
100
|
SQL
|
101
101
|
to_be_replayed << sql
|
102
102
|
|
103
|
-
to_be_deleted_rows << "'#{row[
|
103
|
+
to_be_deleted_rows << "'#{row[audit_table_pk]}'"
|
104
104
|
when "DELETE"
|
105
105
|
sql = <<~SQL
|
106
106
|
DELETE FROM #{shadow_table} WHERE #{primary_key}=\'#{row[primary_key]}\';
|
107
107
|
SQL
|
108
108
|
to_be_replayed << sql
|
109
109
|
|
110
|
-
to_be_deleted_rows << "'#{row[
|
110
|
+
to_be_deleted_rows << "'#{row[audit_table_pk]}'"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -117,7 +117,7 @@ module PgOnlineSchemaChange
|
|
117
117
|
return unless to_be_deleted_rows.count >= 1
|
118
118
|
|
119
119
|
delete_query = <<~SQL
|
120
|
-
DELETE FROM #{audit_table} WHERE #{
|
120
|
+
DELETE FROM #{audit_table} WHERE #{audit_table_pk} IN (#{to_be_deleted_rows.join(",")})
|
121
121
|
SQL
|
122
122
|
Query.run(client.connection, delete_query, reuse_trasaction)
|
123
123
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_online_schema_change
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shayon Mukherjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ougai
|