partition_gardener 0.3.7 → 0.3.9
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/CHANGELOG.md +9 -0
- data/README.md +5 -3
- data/docs/THIRD_PARTY_LICENSE_MANIFEST.tsv +36 -14
- data/docs/changelogs/20261105085411_hot-switch-migration-connection-stack-overflow.md +24 -0
- data/docs/changelogs/20261105090326_cut-patch-release-0-3-8.md +27 -0
- data/docs/changelogs/20261113104337_partman-probe-aborts-open-transactions.md +26 -0
- data/docs/changelogs/20261113110417_opt-in-boot-side-paths.md +25 -0
- data/docs/changelogs/20261113130745_cut-patch-release-0-3-9.md +28 -0
- data/docs/configuration.md +11 -1
- data/docs/cutover.md +2 -0
- data/docs/issues/20261105085411_hot-switch-migration-connection-stack-overflow.md +30 -0
- data/docs/issues/20261113104337_partman-probe-aborts-open-transactions.md +29 -0
- data/docs/issues/20261113110417_opt-in-boot-side-paths.md +36 -0
- data/docs/reviews/20261105085411_engineering-audit-hot-switch-connection.md +38 -0
- data/docs/reviews/20261105090507_engineering-audit-release-preparation.md +42 -0
- data/docs/reviews/20261113130745_engineering-audit-release-preparation.md +46 -0
- data/exe/partition_gardener +2 -0
- data/lib/partition_gardener/connection.rb +7 -0
- data/lib/partition_gardener/migration/hot_switch_concern.rb +33 -28
- data/lib/partition_gardener/rails.rb +11 -6
- data/lib/partition_gardener/railtie.rb +12 -0
- data/lib/partition_gardener/stdlib_extensions.rb +7 -3
- data/lib/partition_gardener/version.rb +1 -1
- data/lib/partition_gardener.rb +6 -6
- metadata +15 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98b92281aeb4170b89c00bb5572877f61f09ae57165466d501ac978b426c12e0
|
|
4
|
+
data.tar.gz: 56ef9a4140d737bc9c056b7a8d212776a7833c2a3ffadc1feaf2d1732554a0ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16d5658b4b310269f3a4c20da3b4b50ae0716b1c411d41c209ec817748b2ce6d08e57a5f4b7dff3dcb416583546f42edd06eeb3133a9a6d5a1000be5836a9eab
|
|
7
|
+
data.tar.gz: 97ed6b345cb06a8ba74023c2cf18ba664c1dac91fbd7d275570d8b81ca8843dbe0494b3861fc7b0e04e777de08c7a7363fb0b171e58e2d36fd2e51e69a8e6b6f
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.3.9 (2026-11-13)
|
|
6
|
+
|
|
7
|
+
- Make Railtie, CLI, HotSwitchConcern, and Integer duration helpers opt-in requires instead of loading them from the default `partition_gardener` require; hosts that need Rails defaults must require `partition_gardener/railtie`, and hot-switch migrations must require `partition_gardener/migration/hot_switch_concern`
|
|
8
|
+
- Fix register-time `partman.part_config` probe so a missing relation does not abort an open Postgres transaction (`PG::InFailedSqlTransaction` after Ruby rescued `StatementInvalid`)
|
|
9
|
+
|
|
10
|
+
## 0.3.8 (2026-11-05)
|
|
11
|
+
|
|
12
|
+
- Fix hot-switch migrations aborting with `SystemStackError` when included into `ActiveRecord::Migration` on Rails 8 (private `connection` override recursed through `DefaultStrategy`)
|
|
13
|
+
|
|
5
14
|
## 0.3.7 (2026-10-29)
|
|
6
15
|
|
|
7
16
|
- Fix rebalance resume so phase `detach` still runs detach and drain until the record advances to `segments`
|
data/README.md
CHANGED
|
@@ -49,8 +49,8 @@ Complements migration gems (e.g. [pg_party](https://github.com/rkrage/pg_party))
|
|
|
49
49
|
## Quick start
|
|
50
50
|
|
|
51
51
|
```ruby
|
|
52
|
-
# Gemfile
|
|
53
|
-
gem "partition_gardener"
|
|
52
|
+
# Gemfile — require the railtie only when you want Rails connection/today defaults
|
|
53
|
+
gem "partition_gardener", require: ["partition_gardener", "partition_gardener/railtie"]
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
```ruby
|
|
@@ -143,9 +143,11 @@ See [docs/partition_landscape.md](docs/partition_landscape.md) for the template
|
|
|
143
143
|
|
|
144
144
|
## Hot-switch migrations
|
|
145
145
|
|
|
146
|
-
`PartitionGardener::Migration::HotSwitchConcern` (alias `HotSwitchPartitionedTable`) consolidates cutover migration helpers.
|
|
146
|
+
`PartitionGardener::Migration::HotSwitchConcern` (alias `HotSwitchPartitionedTable`) consolidates cutover migration helpers. Require it explicitly in the migration file:
|
|
147
147
|
|
|
148
148
|
```ruby
|
|
149
|
+
require "partition_gardener/migration/hot_switch_concern"
|
|
150
|
+
|
|
149
151
|
class PartitionEventsHotSwitch < ActiveRecord::Migration[8.0]
|
|
150
152
|
include PartitionGardener::Migration::HotSwitchConcern
|
|
151
153
|
|
|
@@ -1,42 +1,62 @@
|
|
|
1
1
|
bundle gem version licenses
|
|
2
|
-
root
|
|
3
|
-
root
|
|
4
|
-
root
|
|
2
|
+
root actionpack 8.1.4.1 MIT
|
|
3
|
+
root actionview 8.1.4.1 MIT
|
|
4
|
+
root activemodel 8.1.4.1 MIT
|
|
5
|
+
root activerecord 8.1.4.1 MIT
|
|
6
|
+
root activesupport 8.1.4.1 MIT
|
|
5
7
|
root appraisal 2.5.0 MIT
|
|
6
8
|
root ast 2.4.3 MIT
|
|
7
9
|
root base64 0.3.0 Ruby|BSD-2-Clause
|
|
8
10
|
root bigdecimal 4.1.3 Ruby|BSD-2-Clause
|
|
11
|
+
root builder 3.3.0 MIT
|
|
9
12
|
root bundler 4.0.16 MIT
|
|
10
13
|
root concurrent-ruby 1.3.8 MIT
|
|
11
14
|
root connection_pool 3.0.2 MIT
|
|
15
|
+
root crass 1.0.8 MIT
|
|
12
16
|
root diff-lcs 1.6.2 MIT|Artistic-1.0-Perl|GPL-2.0-or-later
|
|
13
17
|
root drb 2.2.3 Ruby|BSD-2-Clause
|
|
18
|
+
root erb 6.0.7 Ruby|BSD-2-Clause
|
|
19
|
+
root erubi 1.13.1 MIT
|
|
14
20
|
root i18n 1.15.2 MIT
|
|
21
|
+
root io-console 0.9.5 Ruby|BSD-2-Clause
|
|
22
|
+
root irb 1.19.0 Ruby|BSD-2-Clause
|
|
15
23
|
root json 3.1.0 Ruby
|
|
16
24
|
root language_server-protocol 3.17.0.6 MIT
|
|
17
25
|
root lint_roller 1.1.0 MIT
|
|
18
26
|
root logger 1.7.0 Ruby|BSD-2-Clause
|
|
19
|
-
root
|
|
27
|
+
root loofah 2.25.3 MIT
|
|
28
|
+
root minitest 6.1.0 MIT
|
|
29
|
+
root nokogiri 1.19.7 MIT
|
|
20
30
|
root parallel 2.3.0 MIT
|
|
21
31
|
root parser 3.3.13.0 MIT
|
|
22
|
-
root partition_gardener 0.3.
|
|
32
|
+
root partition_gardener 0.3.9 MIT
|
|
23
33
|
root pg 1.6.3 BSD-2-Clause
|
|
24
|
-
root polyrun
|
|
25
|
-
root
|
|
26
|
-
root
|
|
34
|
+
root polyrun 3.0.0 MIT
|
|
35
|
+
root pp 0.6.4 Ruby|BSD-2-Clause
|
|
36
|
+
root prettyprint 0.2.1 Ruby|BSD-2-Clause
|
|
37
|
+
root prism 2.1.0 MIT
|
|
38
|
+
root prosopite 2.5.0 Apache-2.0
|
|
27
39
|
root racc 1.8.1 Ruby|BSD-2-Clause
|
|
28
|
-
root rack 3.2.
|
|
40
|
+
root rack 3.2.8 MIT
|
|
41
|
+
root rack-session 2.1.2 MIT
|
|
42
|
+
root rack-test 2.3.0 MIT
|
|
43
|
+
root rackup 2.3.1 MIT
|
|
44
|
+
root rails-dom-testing 2.3.0 MIT
|
|
45
|
+
root rails-html-sanitizer 1.7.2 MIT
|
|
46
|
+
root railties 8.1.4.1 MIT
|
|
29
47
|
root rainbow 3.1.1 MIT
|
|
30
48
|
root rake 13.4.2 MIT
|
|
31
49
|
root rbs 4.2.0 BSD-2-Clause|Ruby
|
|
50
|
+
root rdoc 8.1.0 Ruby|GPL-2.0-only
|
|
32
51
|
root regexp_parser 2.13.1 MIT
|
|
52
|
+
root reline 0.7.0 Ruby
|
|
33
53
|
root rspec 3.13.2 MIT
|
|
34
|
-
root rspec-core 3.13.
|
|
35
|
-
root rspec-expectations 3.13.
|
|
36
|
-
root rspec-mocks 3.13.
|
|
37
|
-
root rspec-support 3.13.
|
|
54
|
+
root rspec-core 3.13.7 MIT
|
|
55
|
+
root rspec-expectations 3.13.6 MIT
|
|
56
|
+
root rspec-mocks 3.13.9 MIT
|
|
57
|
+
root rspec-support 3.13.8 MIT
|
|
38
58
|
root rubocop 1.91.0 MIT
|
|
39
|
-
root rubocop-ast 1.
|
|
59
|
+
root rubocop-ast 1.51.0 MIT
|
|
40
60
|
root rubocop-capybara 2.23.0 MIT
|
|
41
61
|
root rubocop-factory_bot 2.28.0 MIT
|
|
42
62
|
root rubocop-performance 1.26.1 MIT
|
|
@@ -58,3 +78,5 @@ root tzinfo 2.0.6 MIT
|
|
|
58
78
|
root unicode-display_width 3.3.0 MIT
|
|
59
79
|
root unicode-emoji 4.3.0 MIT
|
|
60
80
|
root uri 1.1.2 Ruby|BSD-2-Clause
|
|
81
|
+
root useragent 0.16.11 MIT
|
|
82
|
+
root zeitwerk 2.8.3 MIT
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Hot-switch migrations including HotSwitchConcern could stack-overflow on Rails 8 when any Migration DSL method ran through DefaultStrategy.
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Rename the concern's connection helper to gardener_connection so ActiveRecord::Migration#connection stays public.
|
|
10
|
+
- Keep hot-switch SQL on gardener_connection.execute (configured resolver), not Migration#execute.
|
|
11
|
+
|
|
12
|
+
## Effects
|
|
13
|
+
|
|
14
|
+
- SystemStackError with repeating `-- connection(nil)` no longer occurs for create_table after include.
|
|
15
|
+
- Cut into CHANGELOG under `## 0.3.8 (2026-11-05)`.
|
|
16
|
+
|
|
17
|
+
## Next
|
|
18
|
+
|
|
19
|
+
- Commit, tag `0.3.8`, push, and run `make release`.
|
|
20
|
+
|
|
21
|
+
## Source
|
|
22
|
+
|
|
23
|
+
- docs/issues/20261105085411_hot-switch-migration-connection-stack-overflow.md
|
|
24
|
+
- docs/reviews/20261105085411_engineering-audit-hot-switch-connection.md
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Cut patch release 0.3.8
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Bump `PartitionGardener::VERSION` to `0.3.8`.
|
|
10
|
+
- Record the Rails 8 hot-switch `SystemStackError` fix in `CHANGELOG.md` under `## 0.3.8 (2026-11-05)`.
|
|
11
|
+
- Stay on `main`. No trunk branch.
|
|
12
|
+
|
|
13
|
+
## Effects
|
|
14
|
+
|
|
15
|
+
- Moved the Unreleased note into the 0.3.8 section.
|
|
16
|
+
- Synced path-gem lockfile versions to 0.3.8.
|
|
17
|
+
|
|
18
|
+
## Next
|
|
19
|
+
|
|
20
|
+
- Commit the prepared tree on `main`, tag `0.3.8`, push, and run `make release` (gem push, tag push, GitHub release).
|
|
21
|
+
|
|
22
|
+
## Source
|
|
23
|
+
|
|
24
|
+
- Fix note: `docs/changelogs/20261105085411_hot-switch-migration-connection-stack-overflow.md`
|
|
25
|
+
- Issue: `docs/issues/20261105085411_hot-switch-migration-connection-stack-overflow.md`
|
|
26
|
+
- Review: `docs/reviews/20261105085411_engineering-audit-hot-switch-connection.md`
|
|
27
|
+
- `CHANGELOG.md`, `lib/partition_gardener/version.rb`
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Register-time partman probe no longer aborts an open transaction when partman.part_config is missing.
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Gate the `partman.part_config` SELECT on `to_regclass(...)::text` so absence is a null result, not an error that marks the transaction aborted.
|
|
10
|
+
- Document that a savepoint wrap also works but costs more on the common no-partman path.
|
|
11
|
+
|
|
12
|
+
## Effects
|
|
13
|
+
|
|
14
|
+
- `Registry.register` / `MaintenanceBackend.validate!` stay safe inside RSpec transactional examples and other outer transactions without pg_partman.
|
|
15
|
+
- Host prepend workarounds that only checked `to_regclass` can be removed after this gem version is locked.
|
|
16
|
+
|
|
17
|
+
## Next
|
|
18
|
+
|
|
19
|
+
- Cut into CHANGELOG under `## 0.3.9 (2026-11-13)`.
|
|
20
|
+
- Commit, tag `0.3.9`, push, and run `make release`.
|
|
21
|
+
|
|
22
|
+
## Source
|
|
23
|
+
|
|
24
|
+
- docs/issues/20261113104337_partman-probe-aborts-open-transactions.md
|
|
25
|
+
- lib/partition_gardener/connection.rb
|
|
26
|
+
- spec/integration/partman_probe_transaction_spec.rb
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Default require no longer pulls Railtie, CLI, HotSwitch, or Integer duration helpers.
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Treat side paths as opt-in requires; document Gemfile and migration require lines.
|
|
10
|
+
- Keep `auto_configure` on the railtie so requiring the railtie remains one clear consent switch.
|
|
11
|
+
|
|
12
|
+
## Effects
|
|
13
|
+
|
|
14
|
+
- Apps boot without gem Railtie configuration unless they require `partition_gardener/railtie`.
|
|
15
|
+
- Cutover migrations and the CLI load only when those entry points are required.
|
|
16
|
+
- Boot footprint report and contract spec capture the default-require inventory.
|
|
17
|
+
|
|
18
|
+
## Next
|
|
19
|
+
|
|
20
|
+
- Cut into CHANGELOG under `## 0.3.9 (2026-11-13)`.
|
|
21
|
+
- Commit, tag `0.3.9`, push, and run `make release`.
|
|
22
|
+
|
|
23
|
+
## Source
|
|
24
|
+
|
|
25
|
+
- docs/issues/20261113110417_opt-in-boot-side-paths.md
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Cut patch release 0.3.9
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Bump `PartitionGardener::VERSION` to `0.3.9`.
|
|
10
|
+
- Record the opt-in boot side paths and partman probe transaction fix in `CHANGELOG.md` under `## 0.3.9 (2026-11-13)`.
|
|
11
|
+
- Stay on `main`. No trunk branch.
|
|
12
|
+
|
|
13
|
+
## Effects
|
|
14
|
+
|
|
15
|
+
- Moved the Unreleased notes into the 0.3.9 section.
|
|
16
|
+
- Synced path-gem lockfile versions to 0.3.9.
|
|
17
|
+
- Tightened boot footprint `$LOADED_FEATURES` matching to `lib/partition_gardener` so checkout paths under `vendor/bundle` are not counted as gardener files.
|
|
18
|
+
- GitHub release notes now come from the matching `CHANGELOG.md` section via `--notes-file` instead of `--generate-notes`.
|
|
19
|
+
|
|
20
|
+
## Next
|
|
21
|
+
|
|
22
|
+
- Commit the prepared tree on `main`, tag `0.3.9`, push, and run `make release` (gem push, tag push, GitHub release).
|
|
23
|
+
|
|
24
|
+
## Source
|
|
25
|
+
|
|
26
|
+
- Fix notes: `docs/changelogs/20261113110417_opt-in-boot-side-paths.md`, `docs/changelogs/20261113104337_partman-probe-aborts-open-transactions.md`
|
|
27
|
+
- Issues: `docs/issues/20261113110417_opt-in-boot-side-paths.md`, `docs/issues/20261113104337_partman-probe-aborts-open-transactions.md`
|
|
28
|
+
- `CHANGELOG.md`, `lib/partition_gardener/version.rb`
|
data/docs/configuration.md
CHANGED
|
@@ -10,6 +10,9 @@ Pick layout and maintainer first ([decision_flow.md](decision_flow.md), [tooling
|
|
|
10
10
|
## Global configuration
|
|
11
11
|
|
|
12
12
|
```ruby
|
|
13
|
+
# Gemfile — railtie is opt-in (sets Active Record + Time.zone defaults)
|
|
14
|
+
gem "partition_gardener", require: ["partition_gardener", "partition_gardener/railtie"]
|
|
15
|
+
|
|
13
16
|
# config/initializers/partition_gardener.rb
|
|
14
17
|
PartitionGardener.configure do |config|
|
|
15
18
|
config.notifier = ->(message_or_error, context: {}) {
|
|
@@ -25,7 +28,14 @@ PartitionGardener.configure do |config|
|
|
|
25
28
|
end
|
|
26
29
|
```
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
Default `require "partition_gardener"` does not load the Railtie, CLI, hot-switch concern, or Integer duration helpers. Opt in:
|
|
32
|
+
|
|
33
|
+
- `require "partition_gardener/railtie"` — Rails defaults for `connection_resolver` and `today_resolver` (disable with `config.partition_gardener.auto_configure = false` in `config/application.rb`)
|
|
34
|
+
- `require "partition_gardener/cli"` — CLI (also loaded by `exe/partition_gardener`)
|
|
35
|
+
- `require "partition_gardener/migration/hot_switch_concern"` — cutover migrations
|
|
36
|
+
- `require "partition_gardener/stdlib_extensions"` then `PartitionGardener.install_stdlib_extensions!` — `Integer#minutes` / `#seconds` when Active Support is absent
|
|
37
|
+
|
|
38
|
+
When the railtie is required and `auto_configure` is true, it sets `connection_resolver` and `today_resolver` during Rails initialization.
|
|
29
39
|
|
|
30
40
|
`notifier` (default: no-op proc) — receives errors and info messages with a `context:` hash (`table_name`, `job`, `action`, …).
|
|
31
41
|
|
data/docs/cutover.md
CHANGED
|
@@ -34,6 +34,8 @@ For cross-database copies (production → staging, or a second cluster during mi
|
|
|
34
34
|
Use `PartitionGardener::Migration::HotSwitchConcern` in a migration:
|
|
35
35
|
|
|
36
36
|
```ruby
|
|
37
|
+
require "partition_gardener/migration/hot_switch_concern"
|
|
38
|
+
|
|
37
39
|
class PartitionEventsHotSwitch < ActiveRecord::Migration[8.0]
|
|
38
40
|
include PartitionGardener::Migration::HotSwitchConcern
|
|
39
41
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Hot-switch migrations that include HotSwitchConcern abort with SystemStackError on Rails 8 while printing many `-- connection(nil)` lines. Local RANGE partition DDL can succeed; the failure is in the migration connection path.
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Stop overriding ActiveRecord::Migration#connection from HotSwitchConcern.
|
|
10
|
+
- Route hot-switch SQL through a private gardener_connection helper and adapter execute, so Strong Migrations still does not see Migration#execute.
|
|
11
|
+
- Prefer Migration @connection when present (multi-db migrate scope); otherwise use PartitionGardener.configuration.connection.
|
|
12
|
+
- Keep Migration#connection public so DefaultStrategy can resolve the adapter without entering method_missing recursion.
|
|
13
|
+
|
|
14
|
+
## Effects
|
|
15
|
+
|
|
16
|
+
- Reproduced before the fix: including HotSwitchConcern, then create_table or execution_strategy.respond_to?(:create_table), overflows through DefaultStrategy#connection -> Migration#method_missing -> respond_to_missing? -> connection again.
|
|
17
|
+
- After the fix: same path completes; Migration#connection owner stays ActiveRecord::Migration.
|
|
18
|
+
- Spec coverage added for the non-recursion contract; focused hot-switch specs pass on Rails 7.2 and Rails 8.1 appraisals.
|
|
19
|
+
|
|
20
|
+
## Next
|
|
21
|
+
|
|
22
|
+
- Publish `0.3.8` (`make release` after commit and clean tree).
|
|
23
|
+
- Host apps pinned on 0.3.7 need `0.3.8` or an equivalent local patch before hot-switch cutover migrations that also use Migration DSL.
|
|
24
|
+
|
|
25
|
+
## Source
|
|
26
|
+
|
|
27
|
+
- lib/partition_gardener/migration/hot_switch_concern.rb
|
|
28
|
+
- activerecord migration DefaultStrategy#connection
|
|
29
|
+
- docs/reviews/20261105085411_engineering-audit-hot-switch-connection.md
|
|
30
|
+
- docs/changelogs/20261105085411_hot-switch-migration-connection-stack-overflow.md
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# When partman.part_config is absent, the register-time probe still aborts an open Postgres transaction after Ruby rescues StatementInvalid.
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Probe with `to_regclass('partman.part_config')::text` before selecting from the table so a missing relation returns null instead of raising.
|
|
10
|
+
- Keep `MaintenanceBackend.partman_parent_configured?` rescue as defense for unrelated statement failures.
|
|
11
|
+
- Prefer `to_regclass` over a savepoint wrap: local measurement showed the missing-relation savepoint path about 3x slower than the catalog null check.
|
|
12
|
+
|
|
13
|
+
## Effects
|
|
14
|
+
|
|
15
|
+
- Reproduced before the fix: `MaintenanceBackend.partman_parent_configured?` returned false inside an open transaction, then `SELECT 1` raised `PG::InFailedSqlTransaction`.
|
|
16
|
+
- After the fix: the same sequence leaves the outer transaction usable; `Registry.register` no longer poisons transactional RSpec examples on DBs without pg_partman.
|
|
17
|
+
- Integration specs cover absent probe, register inside a transaction, and a hit when a stub `partman.part_config` lists the parent.
|
|
18
|
+
|
|
19
|
+
## Next
|
|
20
|
+
|
|
21
|
+
- Publish `0.3.9` (`make release` after commit and clean tree). Host apps can drop prepend workarounds once that version is locked.
|
|
22
|
+
- Optional later: cache the relation presence check across a register burst if register volume ever makes the extra round trip when partman is installed measurable.
|
|
23
|
+
|
|
24
|
+
## Source
|
|
25
|
+
|
|
26
|
+
- lib/partition_gardener/connection.rb (`partman_parent_configured?`)
|
|
27
|
+
- lib/partition_gardener/maintenance_backend.rb
|
|
28
|
+
- spec/integration/partman_probe_transaction_spec.rb
|
|
29
|
+
- docs/changelogs/20261113104337_partman-probe-aborts-open-transactions.md
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Default require loaded CLI, HotSwitch, Railtie (when Rails::Railtie was defined), and an Integer duration monkey-patch without an explicit host opt-in.
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Keep maintenance/register/run on the default require so existing jobs and initializers keep working.
|
|
10
|
+
- Make Railtie, CLI, HotSwitchConcern, and stdlib Integer helpers explicit requires.
|
|
11
|
+
- Railtie uses `config.partition_gardener.auto_configure` (default true once the railtie is loaded) so hosts can require the railtie file without overwriting resolvers.
|
|
12
|
+
- Record boot footprint with `usr/reports/boot_footprint.rb` and a subprocess contract spec.
|
|
13
|
+
|
|
14
|
+
## Effects
|
|
15
|
+
|
|
16
|
+
- Before (this machine, 20 cold subprocesses): mean 37.64 ms, 55 gardener files; Integer duration patch installed when Active Support Duration was absent; CLI and HotSwitch constants always defined; Railtie auto-loaded whenever `Rails::Railtie` was already defined.
|
|
17
|
+
- After (same method, 20 cold subprocesses): mean 34.75 ms, 52 gardener files; CLI / HotSwitch / Railtie / stdlib_extensions absent from default require.
|
|
18
|
+
- Absolute time win is small while the maintenance stack stays eager; the contract win is consent (no silent Railtie or monkey-patch).
|
|
19
|
+
- Specs that use CLI or HotSwitch require those files directly.
|
|
20
|
+
|
|
21
|
+
## Next
|
|
22
|
+
|
|
23
|
+
- Publish `0.3.9` (`make release` after commit and clean tree).
|
|
24
|
+
- Host apps that relied on silent Railtie defaults must add `partition_gardener/railtie` to the Gemfile require list (or set resolvers in an initializer, which many already do).
|
|
25
|
+
- Hot-switch migrations must `require "partition_gardener/migration/hot_switch_concern"`.
|
|
26
|
+
- Optional later: further slim the default require if app boot budgets demand it; keep that behind an explicit runtime entry point rather than silent autoload.
|
|
27
|
+
|
|
28
|
+
## Source
|
|
29
|
+
|
|
30
|
+
- lib/partition_gardener.rb
|
|
31
|
+
- lib/partition_gardener/railtie.rb
|
|
32
|
+
- lib/partition_gardener/rails.rb
|
|
33
|
+
- lib/partition_gardener/stdlib_extensions.rb
|
|
34
|
+
- spec/partition_gardener/boot_footprint_spec.rb
|
|
35
|
+
- usr/reports/boot_footprint.rb
|
|
36
|
+
- docs/changelogs/20261113110417_opt-in-boot-side-paths.md
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Engineering audit of HotSwitchConcern connection handling after a reported SystemStackError on Rails 8 multi-database migrate.
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Claims from the incident note were checked only against this repository and installed ActiveRecord 8.1 sources; no consumer app tree was opened.
|
|
10
|
+
- Root cause is a private connection method on HotSwitchConcern that shadows Migration#connection. DefaultStrategy calls migration.connection with an explicit receiver; that hits Migration#method_missing, which asks execution_strategy.respond_to?, which calls connection again.
|
|
11
|
+
- The `-- connection(nil)` spam is Rails format_arguments on an empty argument list (last is nil), not a literal nil argument from the host.
|
|
12
|
+
- connected_to_stack can appear when the configured resolver calls ActiveRecord::Base.connection; it is on the stack, not the recursion engine.
|
|
13
|
+
- Multi-database migrate context is where the host hit the bug; the overflow reproduces without a second database once the concern is included and Migration DSL runs.
|
|
14
|
+
- schema.rb dropping PARTITION BY is a separate Rails schema dump limitation; out of scope for this connection fix.
|
|
15
|
+
- Boundary and control mode skipped: library SQL helpers, no physical actuators.
|
|
16
|
+
- Product-surface, privacy, learned-systems, lineage modes skipped: no person-facing product surface in this change.
|
|
17
|
+
- Resource and budget: overflow is unbounded stack growth until SystemStackError; fix removes the recursive path (measured: create_table completes after fix).
|
|
18
|
+
- Trace and identification: verbose migration lines are local process stdout only; no new identifiers emitted by the fix.
|
|
19
|
+
|
|
20
|
+
## Effects
|
|
21
|
+
|
|
22
|
+
- Finding F1 confirmed and fixed: private connection override vs DefaultStrategy recursion.
|
|
23
|
+
- Finding F2 confirmed and fixed: gardener_connection prefers Migration @connection when exec_migration set it, else configuration.connection_resolver, so multi-db migrate SQL stays on the migration-scoped adapter.
|
|
24
|
+
- Regression specs added; rails8ruby34 and rails72 focused suites green for hot_switch_concern_spec.
|
|
25
|
+
- Second pass: no other HotSwitchConcern methods shadow Migration DSL entry points (execute, transaction, say).
|
|
26
|
+
|
|
27
|
+
## Next
|
|
28
|
+
|
|
29
|
+
- Publish `0.3.8` after commit on a clean tree (`make release`).
|
|
30
|
+
- Cutover docs do not imply overriding `Migration#connection`; no doc change required for this fix.
|
|
31
|
+
|
|
32
|
+
## Source
|
|
33
|
+
|
|
34
|
+
- lib/partition_gardener/migration/hot_switch_concern.rb
|
|
35
|
+
- lib/partition_gardener/rails.rb
|
|
36
|
+
- lib/partition_gardener/configuration.rb
|
|
37
|
+
- spec/partition_gardener/migration/hot_switch_concern_spec.rb
|
|
38
|
+
- activerecord-8.1.3 lib/active_record/migration/default_strategy.rb
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Engineering audit and release preparation
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Continue on main while preserving uncommitted work. Do not commit, tag, push, or publish in this session.
|
|
10
|
+
- Cut patch release version 0.3.8 for the Rails 8 hot-switch `SystemStackError` fix. Set the CHANGELOG heading date to 2026-11-05.
|
|
11
|
+
- Re-check lint, executable coverage, workflow YAML parse, package boundaries, and cold-require cost after the cut.
|
|
12
|
+
|
|
13
|
+
## Effects
|
|
14
|
+
|
|
15
|
+
- Bump `PartitionGardener::VERSION` and path-gem lockfiles to 0.3.8. Move the Unreleased bullet under `## 0.3.8 (2026-11-05)`.
|
|
16
|
+
- Fix rubocop offenses in `hot_switch_concern_spec` introduced by the connection helper rewrite (`RSpec/InstanceVariable`, `Layout/EmptyLineBetweenDefs`).
|
|
17
|
+
- Final serial JSON report: 190 examples, 0 failures with `INTEGRATION=1` and PostgreSQL on port 5432; no pending examples. Parallel polyrun with five workers: exit 0.
|
|
18
|
+
- Required project checks passed: rubocop (116 files, no offenses), rbs validate, `INTEGRATION=1` polyrun parallel-rspec. Environment: Ruby 4.0.2, `BUNDLE_PATH=vendor/bundle`.
|
|
19
|
+
- `release_spec`: 2 examples, 0 failures.
|
|
20
|
+
- Build the gem, verify it with `Gem::Package#verify`, and confirm the changelog heading matches version 0.3.8. Compressed package: 121344 bytes; source payload: 421347 bytes across 109 packaged paths. These are compressed versus uncompressed sizes, not interchangeable quantities.
|
|
21
|
+
- Cold process measurement on macOS arm64 with `/usr/bin/time -p` and `bundle exec ruby -Ilib`: 0.18 CPU seconds, 0.26 elapsed seconds. Peak RSS via `/usr/bin/time -l`: 31293440 bytes. Local smoke ceilings: 1 MiB compressed gem, 128 MiB RSS, 2 CPU seconds. Measured gem size, RSS, and CPU fit those ceilings. CPU seconds are the energy proxy; electricity use was not measured.
|
|
22
|
+
- Parse every workflow YAML, verify lockfile own-gem versions at 0.3.8, and run `git diff --check`. All passed.
|
|
23
|
+
|
|
24
|
+
## Next
|
|
25
|
+
|
|
26
|
+
- Commit, tag 0.3.8, push, and publish remain operator steps; this session did not run them. When the tree is clean, `make release` runs gem push, tag, and GitHub release.
|
|
27
|
+
- Hosted GitHub Actions and the complete supported Ruby/framework matrix were not executed locally beyond the default Gemfile path used by `make test`.
|
|
28
|
+
- Scope limits: production traffic, production database size and query plans, external service retention, and co-located resource interference were not measured. The local byte/CPU results do not establish those properties.
|
|
29
|
+
- Trace review follows local file/log and protocol emissions. No live customer identities or credentials were used. Data retention and deletion in embedding applications remain host contracts.
|
|
30
|
+
- Learned-system training/evaluation and cloud deployment modes do not apply to this library tree. Database-boundary mode applies to PostgreSQL maintenance DDL and hot-switch migration SQL. The library has no independent production health endpoint to assess.
|
|
31
|
+
|
|
32
|
+
## Source
|
|
33
|
+
|
|
34
|
+
- AGENTS.md
|
|
35
|
+
- .agents/skills/engineering-audit/SKILL.md
|
|
36
|
+
- .agents/skills/changelog-update/SKILL.md
|
|
37
|
+
- CHANGELOG.md
|
|
38
|
+
- Makefile
|
|
39
|
+
- spec/README.md
|
|
40
|
+
- docs/reviews/20261105085411_engineering-audit-hot-switch-connection.md
|
|
41
|
+
- docs/changelogs/20261105090326_cut-patch-release-0-3-8.md
|
|
42
|
+
- docs/changelogs/20261105085411_hot-switch-migration-connection-stack-overflow.md
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Engineering audit and release preparation
|
|
2
|
+
|
|
3
|
+
## Participants
|
|
4
|
+
|
|
5
|
+
Andrei Makarov (@amkisko)
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
|
|
9
|
+
- Continue on main. Do not commit, tag, push, or publish in this session.
|
|
10
|
+
- Cut patch release version 0.3.9 for opt-in boot side paths and the partman probe transaction fix. Set the CHANGELOG heading date to 2026-11-13.
|
|
11
|
+
- Re-check lint, executable coverage, workflow YAML parse, package boundaries, and cold-require cost after the cut.
|
|
12
|
+
|
|
13
|
+
## Effects
|
|
14
|
+
|
|
15
|
+
- Bump `PartitionGardener::VERSION` and path-gem lockfiles to 0.3.9. Move the Unreleased bullets under `## 0.3.9 (2026-11-13)`.
|
|
16
|
+
- Fix boot footprint counting so paths under a checkout named `partition_gardener.rb` (including `vendor/bundle`) do not inflate `gardener_files`. Loose filter reported 68; `lib/partition_gardener` filter reports 52 and restores the `< 55` contract.
|
|
17
|
+
- Publish GitHub release body from the matching `CHANGELOG.md` section (`gh release create --notes-file`), not commit auto-notes.
|
|
18
|
+
- Final serial JSON report: 196 examples, 0 failures with `INTEGRATION=1` and PostgreSQL; no pending examples. Parallel polyrun with five workers: exit 0.
|
|
19
|
+
- Required project checks passed: rubocop (84 files, no offenses), rbs validate, `INTEGRATION=1` polyrun parallel-rspec. Environment: Ruby 4.0.2, `BUNDLE_PATH=vendor/bundle`.
|
|
20
|
+
- `release_spec`: 2 examples, 0 failures.
|
|
21
|
+
- Build the gem, verify it with `Gem::Package#verify`, and confirm the changelog heading matches version 0.3.9. Compressed package: 124928 bytes; source payload: 433997 bytes across 116 packaged paths. These are compressed versus uncompressed sizes, not interchangeable quantities.
|
|
22
|
+
- Cold process measurement on macOS arm64 with `/usr/bin/time -p` and `bundle exec ruby -Ilib`: 0.17 CPU seconds, 0.25 elapsed seconds. Peak RSS via `/usr/bin/time -l`: 30687232 bytes. Local smoke ceilings: 1 MiB compressed gem, 128 MiB RSS, 2 CPU seconds. Measured gem size, RSS, and CPU fit those ceilings. CPU seconds are the energy proxy; electricity use was not measured.
|
|
23
|
+
- Parse every workflow YAML, verify lockfile own-gem versions at 0.3.9, and run `git diff --check`. All passed. RubyGems has no `0.3.9` yet.
|
|
24
|
+
|
|
25
|
+
## Next
|
|
26
|
+
|
|
27
|
+
- Commit, tag 0.3.9, push, and publish remain operator steps; this session did not run them. When the tree is clean, `make release` runs gem push, tag, and GitHub release.
|
|
28
|
+
- Host apps that relied on silent Railtie defaults must require `partition_gardener/railtie`. Hot-switch migrations must require `partition_gardener/migration/hot_switch_concern`.
|
|
29
|
+
- Hosted GitHub Actions and the complete supported Ruby/framework matrix were not executed locally beyond the default Gemfile path used by `make test`.
|
|
30
|
+
- Scope limits: production traffic, production database size and query plans, external service retention, and co-located resource interference were not measured. The local byte/CPU results do not establish those properties.
|
|
31
|
+
- Trace review follows local file/log and protocol emissions. No live customer identities or credentials were used. Data retention and deletion in embedding applications remain host contracts.
|
|
32
|
+
- Database-boundary mode applies to PostgreSQL maintenance DDL and the register-time partman catalog probe.
|
|
33
|
+
|
|
34
|
+
## Source
|
|
35
|
+
|
|
36
|
+
- AGENTS.md
|
|
37
|
+
- .agents/skills/engineering-audit/SKILL.md
|
|
38
|
+
- .agents/skills/changelog-update/SKILL.md
|
|
39
|
+
- CHANGELOG.md
|
|
40
|
+
- Makefile
|
|
41
|
+
- spec/README.md
|
|
42
|
+
- docs/changelogs/20261113130745_cut-patch-release-0-3-9.md
|
|
43
|
+
- docs/changelogs/20261113110417_opt-in-boot-side-paths.md
|
|
44
|
+
- docs/changelogs/20261113104337_partman-probe-aborts-open-transactions.md
|
|
45
|
+
- docs/issues/20261113110417_opt-in-boot-side-paths.md
|
|
46
|
+
- docs/issues/20261113104337_partman-probe-aborts-open-transactions.md
|
data/exe/partition_gardener
CHANGED
|
@@ -246,6 +246,13 @@ module PartitionGardener
|
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
def partman_parent_configured?(table_name)
|
|
249
|
+
# to_regclass returns null when the relation is missing; a direct SELECT would
|
|
250
|
+
# abort an open transaction even if Ruby rescues StatementInvalid.
|
|
251
|
+
relation = connection.execute(
|
|
252
|
+
"SELECT to_regclass('partman.part_config')::text AS relation_oid"
|
|
253
|
+
).first
|
|
254
|
+
return false if Blank.blank?(relation&.fetch("relation_oid", nil))
|
|
255
|
+
|
|
249
256
|
qualified_name = "#{schema_name}.#{table_name}"
|
|
250
257
|
sql = <<~SQL
|
|
251
258
|
SELECT 1
|
|
@@ -42,7 +42,7 @@ module PartitionGardener
|
|
|
42
42
|
|
|
43
43
|
all_months.each do |identifier|
|
|
44
44
|
partition_name = partition_name_format.call(identifier).gsub(/^#{current_table}_/, "#{partitioned_table}_")
|
|
45
|
-
next if
|
|
45
|
+
next if gardener_connection.table_exists?(partition_name)
|
|
46
46
|
|
|
47
47
|
for_values_clause = partition_definition.call(identifier)
|
|
48
48
|
sql = <<~SQL
|
|
@@ -149,12 +149,12 @@ module PartitionGardener
|
|
|
149
149
|
derived_columns = config[:derived_columns] || {}
|
|
150
150
|
stale_column = config[:sync_stale_column] || "updated_at"
|
|
151
151
|
base_key = partition_key_column.to_s.split("::").first.strip
|
|
152
|
-
current_partition_key_expression = config[:current_partition_key_expression] || "s.#{
|
|
152
|
+
current_partition_key_expression = config[:current_partition_key_expression] || "s.#{gardener_connection.quote_column_name(base_key)}"
|
|
153
153
|
today = PartitionGardener.configuration.today
|
|
154
154
|
start_date = DateCalendar.add_months(today, -3)
|
|
155
155
|
end_date = DateCalendar.add_months(today, 3)
|
|
156
|
-
start_date_sql =
|
|
157
|
-
end_date_sql =
|
|
156
|
+
start_date_sql = gardener_connection.quote(start_date)
|
|
157
|
+
end_date_sql = gardener_connection.quote(end_date)
|
|
158
158
|
|
|
159
159
|
say "Syncing delta data from #{source_table} to #{target_table}"
|
|
160
160
|
|
|
@@ -162,26 +162,26 @@ module PartitionGardener
|
|
|
162
162
|
partitioned_columns = table_columns(target_table)
|
|
163
163
|
common_columns = current_columns & partitioned_columns
|
|
164
164
|
insert_columns = (common_columns + derived_columns.keys) & partitioned_columns
|
|
165
|
-
columns_str = insert_columns.map { |column|
|
|
165
|
+
columns_str = insert_columns.map { |column| gardener_connection.quote_column_name(column) }.join(", ")
|
|
166
166
|
inner_select_columns_str = insert_columns.map do |column|
|
|
167
167
|
if derived_columns.key?(column)
|
|
168
|
-
"#{derived_columns[column]} AS #{
|
|
168
|
+
"#{derived_columns[column]} AS #{gardener_connection.quote_column_name(column)}"
|
|
169
169
|
else
|
|
170
|
-
"s.#{
|
|
170
|
+
"s.#{gardener_connection.quote_column_name(column)}"
|
|
171
171
|
end
|
|
172
172
|
end.join(", ")
|
|
173
173
|
|
|
174
|
-
conflict_key_str = conflict_key.map { |column|
|
|
175
|
-
conflict_match = conflict_key.map { |column| "d.#{
|
|
174
|
+
conflict_key_str = conflict_key.map { |column| gardener_connection.quote_column_name(column) }.join(", ")
|
|
175
|
+
conflict_match = conflict_key.map { |column| "d.#{gardener_connection.quote_column_name(column)} = s.#{gardener_connection.quote_column_name(column)}" }.join(" AND ")
|
|
176
176
|
update_columns = insert_columns - conflict_key
|
|
177
|
-
update_clause = update_columns.map { |column| "#{
|
|
177
|
+
update_clause = update_columns.map { |column| "#{gardener_connection.quote_column_name(column)} = EXCLUDED.#{gardener_connection.quote_column_name(column)}" }.join(", ")
|
|
178
178
|
unless current_columns.include?(stale_column) && partitioned_columns.include?(stale_column)
|
|
179
179
|
raise ArgumentError,
|
|
180
180
|
"sync_stale_column #{stale_column.inspect} is missing from source or target; " \
|
|
181
181
|
"refusing unbounded delta sync"
|
|
182
182
|
end
|
|
183
183
|
|
|
184
|
-
stale_check = "d.#{
|
|
184
|
+
stale_check = "d.#{gardener_connection.quote_column_name(stale_column)} >= s.#{gardener_connection.quote_column_name(stale_column)}"
|
|
185
185
|
window_predicate = [
|
|
186
186
|
"#{current_partition_key_expression} >= #{start_date_sql}",
|
|
187
187
|
"AND #{current_partition_key_expression} < #{end_date_sql}",
|
|
@@ -191,7 +191,7 @@ module PartitionGardener
|
|
|
191
191
|
"AND #{stale_check}",
|
|
192
192
|
")"
|
|
193
193
|
].join(" ")
|
|
194
|
-
order_clause = conflict_key.map { |column| "s.#{
|
|
194
|
+
order_clause = conflict_key.map { |column| "s.#{gardener_connection.quote_column_name(column)}" }.join(", ")
|
|
195
195
|
|
|
196
196
|
count_sql = <<~SQL
|
|
197
197
|
SELECT COUNT(*) AS count
|
|
@@ -215,7 +215,7 @@ module PartitionGardener
|
|
|
215
215
|
<<~SQL.chomp
|
|
216
216
|
ON CONFLICT (#{conflict_key_str}) DO UPDATE SET
|
|
217
217
|
#{update_clause}
|
|
218
|
-
WHERE #{quoted_table(target_table)}.#{
|
|
218
|
+
WHERE #{quoted_table(target_table)}.#{gardener_connection.quote_column_name(stale_column)} < EXCLUDED.#{gardener_connection.quote_column_name(stale_column)}
|
|
219
219
|
SQL
|
|
220
220
|
end
|
|
221
221
|
|
|
@@ -249,8 +249,8 @@ module PartitionGardener
|
|
|
249
249
|
sql = <<~SQL
|
|
250
250
|
SELECT column_name
|
|
251
251
|
FROM information_schema.columns
|
|
252
|
-
WHERE table_schema = #{
|
|
253
|
-
AND table_name = #{
|
|
252
|
+
WHERE table_schema = #{gardener_connection.quote(PartitionGardener.configuration.schema_name)}
|
|
253
|
+
AND table_name = #{gardener_connection.quote(table_name)}
|
|
254
254
|
ORDER BY ordinal_position
|
|
255
255
|
SQL
|
|
256
256
|
|
|
@@ -283,7 +283,7 @@ module PartitionGardener
|
|
|
283
283
|
sql = <<~SQL
|
|
284
284
|
SELECT inhrelid::regclass AS child
|
|
285
285
|
FROM pg_catalog.pg_inherits
|
|
286
|
-
WHERE inhparent = #{
|
|
286
|
+
WHERE inhparent = #{gardener_connection.quote(table_name)}::regclass
|
|
287
287
|
SQL
|
|
288
288
|
run_sql(sql).map { |row| row["child"] }
|
|
289
289
|
end
|
|
@@ -294,7 +294,7 @@ module PartitionGardener
|
|
|
294
294
|
partitioned_table = config[:partitioned_table]
|
|
295
295
|
old_table = "#{current_table}_old"
|
|
296
296
|
|
|
297
|
-
return if
|
|
297
|
+
return if gardener_connection.table_exists?(old_table)
|
|
298
298
|
|
|
299
299
|
say "Performing hot switch: #{current_table} -> #{partitioned_table}"
|
|
300
300
|
|
|
@@ -323,8 +323,8 @@ module PartitionGardener
|
|
|
323
323
|
partitioned_table = config[:partitioned_table]
|
|
324
324
|
old_table = "#{current_table}_old"
|
|
325
325
|
|
|
326
|
-
return unless
|
|
327
|
-
return if
|
|
326
|
+
return unless gardener_connection.table_exists?(old_table)
|
|
327
|
+
return if gardener_connection.table_exists?(partitioned_table)
|
|
328
328
|
|
|
329
329
|
say "Performing hot unswitch: #{current_table} -> #{partitioned_table}"
|
|
330
330
|
|
|
@@ -351,7 +351,7 @@ module PartitionGardener
|
|
|
351
351
|
|
|
352
352
|
table_columns(table_name).filter_map do |column_name|
|
|
353
353
|
sql = <<~SQL
|
|
354
|
-
SELECT pg_get_serial_sequence(#{
|
|
354
|
+
SELECT pg_get_serial_sequence(#{gardener_connection.quote(qualified_table)}, #{gardener_connection.quote(column_name)}) AS sequence_name
|
|
355
355
|
SQL
|
|
356
356
|
result = run_sql(sql).first
|
|
357
357
|
sequence_name = result["sequence_name"]
|
|
@@ -397,7 +397,7 @@ module PartitionGardener
|
|
|
397
397
|
timeout = swap_lock_timeout_setting
|
|
398
398
|
return if timeout.nil?
|
|
399
399
|
|
|
400
|
-
run_sql "SET LOCAL lock_timeout = #{
|
|
400
|
+
run_sql "SET LOCAL lock_timeout = #{gardener_connection.quote(timeout)}"
|
|
401
401
|
end
|
|
402
402
|
|
|
403
403
|
def rename_partition_children!(parent_table, from_prefix, to_prefix)
|
|
@@ -409,23 +409,23 @@ module PartitionGardener
|
|
|
409
409
|
new_bare_name = bare_name.sub(from_prefix, to_prefix)
|
|
410
410
|
next if new_bare_name == bare_name
|
|
411
411
|
|
|
412
|
-
run_sql "ALTER TABLE #{partition} RENAME TO #{
|
|
412
|
+
run_sql "ALTER TABLE #{partition} RENAME TO #{gardener_connection.quote_column_name(new_bare_name)}"
|
|
413
413
|
say "Renamed #{partition} to #{new_bare_name}"
|
|
414
414
|
end
|
|
415
415
|
end
|
|
416
416
|
|
|
417
417
|
def repoint_serial_sequences!(table_name, sequence_pairs)
|
|
418
418
|
sequence_pairs.each do |column_name, sequence_name|
|
|
419
|
-
quoted_column =
|
|
419
|
+
quoted_column = gardener_connection.quote_column_name(column_name)
|
|
420
420
|
live_table = quoted_table(table_name)
|
|
421
421
|
run_sql <<~SQL
|
|
422
422
|
ALTER TABLE #{live_table}
|
|
423
423
|
ALTER COLUMN #{quoted_column}
|
|
424
|
-
SET DEFAULT nextval(#{
|
|
424
|
+
SET DEFAULT nextval(#{gardener_connection.quote(sequence_name)}::regclass)
|
|
425
425
|
SQL
|
|
426
426
|
run_sql "ALTER SEQUENCE #{sequence_name} OWNED BY #{live_table}.#{quoted_column}"
|
|
427
427
|
max_id = run_sql("SELECT COALESCE(MAX(#{quoted_column}), 1) AS max_id FROM #{live_table}").first["max_id"].to_i
|
|
428
|
-
run_sql "SELECT setval(#{
|
|
428
|
+
run_sql "SELECT setval(#{gardener_connection.quote(sequence_name)}, #{[max_id, 1].max})"
|
|
429
429
|
say "Repointed #{sequence_name} to #{table_name}.#{column_name}"
|
|
430
430
|
end
|
|
431
431
|
end
|
|
@@ -440,15 +440,20 @@ module PartitionGardener
|
|
|
440
440
|
end
|
|
441
441
|
|
|
442
442
|
def run_sql(sql)
|
|
443
|
-
|
|
443
|
+
gardener_connection.execute(sql)
|
|
444
444
|
end
|
|
445
445
|
|
|
446
|
-
|
|
446
|
+
# ActiveRecord::Migration#exec_migration assigns @connection for the target database.
|
|
447
|
+
# Prefer that adapter during migrate; otherwise use the configured resolver.
|
|
448
|
+
def gardener_connection
|
|
449
|
+
migration_connection = instance_variable_get(:@connection) if instance_variable_defined?(:@connection)
|
|
450
|
+
return migration_connection if migration_connection
|
|
451
|
+
|
|
447
452
|
PartitionGardener.configuration.connection
|
|
448
453
|
end
|
|
449
454
|
|
|
450
455
|
def quoted_table(name)
|
|
451
|
-
|
|
456
|
+
gardener_connection.quote_table_name(name)
|
|
452
457
|
end
|
|
453
458
|
end
|
|
454
459
|
end
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
require "rails"
|
|
2
|
-
|
|
3
1
|
module PartitionGardener
|
|
4
2
|
class Railtie < Rails::Railtie
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
config.partition_gardener = ActiveSupport::OrderedOptions.new
|
|
4
|
+
# Requiring partition_gardener/railtie opts in; set false to load the railtie
|
|
5
|
+
# without overwriting connection_resolver / today_resolver.
|
|
6
|
+
config.partition_gardener.auto_configure = true
|
|
7
|
+
|
|
8
|
+
initializer "partition_gardener.connection" do |app|
|
|
9
|
+
next unless app.config.partition_gardener.auto_configure
|
|
10
|
+
|
|
11
|
+
PartitionGardener.configure do |configuration|
|
|
12
|
+
configuration.connection_resolver = -> { ActiveRecord::Base.connection }
|
|
13
|
+
configuration.today_resolver = -> { Time.zone.today }
|
|
9
14
|
end
|
|
10
15
|
end
|
|
11
16
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Opt-in Rails integration. Host apps that want Active Record and Time.zone
|
|
2
|
+
# defaults should require this file (Gemfile require list or an initializer).
|
|
3
|
+
#
|
|
4
|
+
# gem "partition_gardener", require: ["partition_gardener", "partition_gardener/railtie"]
|
|
5
|
+
#
|
|
6
|
+
# Or:
|
|
7
|
+
#
|
|
8
|
+
# # config/application.rb / an initializer
|
|
9
|
+
# require "partition_gardener/railtie"
|
|
10
|
+
#
|
|
11
|
+
require "rails/railtie"
|
|
12
|
+
require_relative "rails"
|
|
@@ -8,8 +8,12 @@ module PartitionGardener
|
|
|
8
8
|
self
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
|
-
end
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
# Opt-in for non-ActiveSupport hosts (CLI/scripts). Rails apps already have Duration.
|
|
13
|
+
def self.install_stdlib_extensions!
|
|
14
|
+
return if defined?(ActiveSupport::Duration)
|
|
15
|
+
return if Integer.included_modules.include?(IntegerDurationMethods)
|
|
16
|
+
|
|
17
|
+
Integer.include(IntegerDurationMethods)
|
|
18
|
+
end
|
|
15
19
|
end
|
data/lib/partition_gardener.rb
CHANGED
|
@@ -3,8 +3,6 @@ require "date"
|
|
|
3
3
|
require_relative "partition_gardener/version"
|
|
4
4
|
require_relative "partition_gardener/date_calendar"
|
|
5
5
|
require_relative "partition_gardener/date_bucket"
|
|
6
|
-
require_relative "partition_gardener/stdlib_extensions"
|
|
7
|
-
require "pg"
|
|
8
6
|
require_relative "partition_gardener/pg_connection"
|
|
9
7
|
require_relative "partition_gardener/blank"
|
|
10
8
|
require_relative "partition_gardener/predicate"
|
|
@@ -53,8 +51,12 @@ require_relative "partition_gardener/audit"
|
|
|
53
51
|
require_relative "partition_gardener/archive_retention"
|
|
54
52
|
require_relative "partition_gardener/registry"
|
|
55
53
|
require_relative "partition_gardener/config_document"
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
|
|
55
|
+
# Side paths are opt-in (not loaded by default require):
|
|
56
|
+
# require "partition_gardener/cli"
|
|
57
|
+
# require "partition_gardener/migration/hot_switch_concern"
|
|
58
|
+
# require "partition_gardener/railtie"
|
|
59
|
+
# require "partition_gardener/stdlib_extensions" then PartitionGardener.install_stdlib_extensions!
|
|
58
60
|
|
|
59
61
|
module PartitionGardener
|
|
60
62
|
MOVE_BATCH_SIZE = 10_000
|
|
@@ -213,5 +215,3 @@ module PartitionGardener
|
|
|
213
215
|
private :plan_all, :emit_run_metadata, :run_single_table!
|
|
214
216
|
end
|
|
215
217
|
end
|
|
216
|
-
|
|
217
|
-
require_relative "partition_gardener/rails" if defined?(Rails::Railtie)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: partition_gardener
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrei Makarov
|
|
@@ -85,14 +85,14 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - ">="
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 2.2.
|
|
88
|
+
version: 2.2.9
|
|
89
89
|
type: :development
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - ">="
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 2.2.
|
|
95
|
+
version: 2.2.9
|
|
96
96
|
- !ruby/object:Gem::Dependency
|
|
97
97
|
name: prosopite
|
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -279,6 +279,11 @@ files:
|
|
|
279
279
|
- docs/changelogs/20261005135700_checkpoint-table-name.md
|
|
280
280
|
- docs/changelogs/20261005141621_cut-patch-release-0-3-6.md
|
|
281
281
|
- docs/changelogs/20261021220000_cut-patch-release-0-3-7.md
|
|
282
|
+
- docs/changelogs/20261105085411_hot-switch-migration-connection-stack-overflow.md
|
|
283
|
+
- docs/changelogs/20261105090326_cut-patch-release-0-3-8.md
|
|
284
|
+
- docs/changelogs/20261113104337_partman-probe-aborts-open-transactions.md
|
|
285
|
+
- docs/changelogs/20261113110417_opt-in-boot-side-paths.md
|
|
286
|
+
- docs/changelogs/20261113130745_cut-patch-release-0-3-9.md
|
|
282
287
|
- docs/cli.md
|
|
283
288
|
- docs/configuration.md
|
|
284
289
|
- docs/cutover.md
|
|
@@ -289,6 +294,9 @@ files:
|
|
|
289
294
|
- docs/issues/20260909164000_shipped-contract-rfcs.md
|
|
290
295
|
- docs/issues/20260916113300_opaque-composite-public-ids.md
|
|
291
296
|
- docs/issues/20260917123253_ci-drop-automatic-dependency-audit.md
|
|
297
|
+
- docs/issues/20261105085411_hot-switch-migration-connection-stack-overflow.md
|
|
298
|
+
- docs/issues/20261113104337_partman-probe-aborts-open-transactions.md
|
|
299
|
+
- docs/issues/20261113110417_opt-in-boot-side-paths.md
|
|
292
300
|
- docs/monitoring.md
|
|
293
301
|
- docs/naming.md
|
|
294
302
|
- docs/operations.md
|
|
@@ -300,6 +308,9 @@ files:
|
|
|
300
308
|
- docs/reviews/20261021220000_engineering-audit-0-3-7.md
|
|
301
309
|
- docs/reviews/20261028075216_engineering-audit-release-preparation.md
|
|
302
310
|
- docs/reviews/20261029150855_engineering-audit-release-preparation.md
|
|
311
|
+
- docs/reviews/20261105085411_engineering-audit-hot-switch-connection.md
|
|
312
|
+
- docs/reviews/20261105090507_engineering-audit-release-preparation.md
|
|
313
|
+
- docs/reviews/20261113130745_engineering-audit-release-preparation.md
|
|
303
314
|
- docs/schemas/partition_garden.schema.json
|
|
304
315
|
- docs/schemas/plan_report.schema.json
|
|
305
316
|
- docs/tooling_split.md
|
|
@@ -344,6 +355,7 @@ files:
|
|
|
344
355
|
- lib/partition_gardener/predicate.rb
|
|
345
356
|
- lib/partition_gardener/premake_monthly_maintenance.rb
|
|
346
357
|
- lib/partition_gardener/rails.rb
|
|
358
|
+
- lib/partition_gardener/railtie.rb
|
|
347
359
|
- lib/partition_gardener/registry.rb
|
|
348
360
|
- lib/partition_gardener/run_failed.rb
|
|
349
361
|
- lib/partition_gardener/run_metrics.rb
|