postgres-vacuum-monitor 0.14.1 → 0.16.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69b9ab0ab38b8ec69526528cb1893179203086c9e5e1859c261fc54fafb19c34
4
- data.tar.gz: 386c009018d2c6490c500f1d440c09d95dd0c4547eccb7b4710b6769a43c192b
3
+ metadata.gz: 3d9e8b90692a2b1bbadc40202497aae4af9a3e088b8c5a47869396ba5d14e796
4
+ data.tar.gz: 7db2e649f6c350a613e6b765f0cf9fe4f10cae9a4b0aa05f47a585519a029ad3
5
5
  SHA512:
6
- metadata.gz: '035934d78adbfcc04a56390b2ec94deccdc1a53c4bdaf6b6f138cb951e595f10e388bb7084bff3590943698e8d6c026cc2c2d22926adea3d4edf8df2a326c2c7'
7
- data.tar.gz: 2d9864aecd3b5d70c2c00a47bc16eb054edc408e6e5a19402886584347545eedc4322b2165eb628f460f93baf1519c42279af970628cd591422e8d87095f265f
6
+ metadata.gz: 7668c76a3666dfa35a70c26a923b2a9aebd1f0d1d96c3f4f5fe868dcba9c6f2ec4e15edcf1dbba07b17ab460b04d898c3468709e0dfd54532d6b503ca02f63f7
7
+ data.tar.gz: 284047bdc67471afda8abc017e377d3536de6e1593bfcc9993bc8ff16d5be562194b4f552f36ef150259c51b34571fcfc5b6ada56767da6fb2469d48c50aeca0
data/.circleci/config.yml CHANGED
@@ -38,12 +38,10 @@ jobs:
38
38
  type: string
39
39
  ruby_version:
40
40
  type: string
41
- postgres_version:
42
- type: string
43
41
  docker:
44
42
  - image: $SALSIFY_ECR_REPO/ruby_ci:<< parameters.ruby_version >>
45
43
  <<: *aws-auth
46
- - image: cimg/postgres:<< parameters.postgres_version >>
44
+ - image: cimg/postgres:14.7
47
45
  environment:
48
46
  POSTGRES_USER: "circleci"
49
47
  POSTGRES_DB: "circle_test"
@@ -98,10 +96,8 @@ workflows:
98
96
  gemfile:
99
97
  - "gemfiles/activerecord_6_1.gemfile"
100
98
  - "gemfiles/activerecord_7_0.gemfile"
99
+ - "gemfiles/activerecord_7_1.gemfile"
101
100
  ruby_version:
102
101
  - "3.0.6"
103
102
  - "3.1.4"
104
103
  - "3.2.2"
105
- postgres_version:
106
- - "12.9"
107
- - "14.7"
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @fgarces @will89
1
+ * @salsify/pim-core-backend
data/Appraisals CHANGED
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'activerecord_6_0' do
4
- gem 'activerecord', '~> 6.0.0'
5
- end
6
-
7
3
  appraise 'activerecord_6_1' do
8
- gem 'activerecord', '~> 6.1.0'
4
+ gem 'activerecord', '~> 6.1.7.6'
9
5
  end
10
6
 
11
7
  appraise 'activerecord_7_0' do
12
- gem 'activerecord', '~> 7.0.0'
8
+ gem 'activerecord', '~> 7.0.8'
9
+ end
10
+
11
+ appraise 'activerecord_7_1' do
12
+ gem 'activerecord', '~> 7.1.1'
13
13
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # postgres-vacuum-monitor
2
2
 
3
+ ## v0.16.0
4
+ - Add `max_attempts` and `max_run_time` to `Postgres::Vacuum::Jobs::MonitorJob` to avoid backing up the queue. The
5
+ defaults are 1 attempt and 10 seconds, but they can be configured with `monitor_max_attempts` and
6
+ `monitor_max_run_time_seconds`, respectively.
7
+
8
+ ## v0.15.0
9
+ - Add support for Rails 7.1
10
+
3
11
  ## v0.14.1
4
12
  - Requires activerecord >= 6.1
5
13
 
data/README.md CHANGED
@@ -34,7 +34,11 @@ The job itself needs a class to report the information and can be configured by
34
34
  Postgres::Vacuum::Monitor.configure do |config|
35
35
  config.monitor_reporter_class_name = 'MetricsReporter'
36
36
  # Optionally change the default threshold of 5 minutes for reporting long running transactions
37
- config.long_running_transaction_threshold_seconds = 10 * 60
37
+ config.long_running_transaction_threshold_seconds = 10 * 60
38
+ # Optionally change `max_attempts` of the monitor job (default 1)
39
+ config.monitor_max_attempts = 3
40
+ # Optionally change `max_run_time` of the monitor job (default 10 seconds)
41
+ config.monitor_max_run_time_seconds = 5
38
42
  end
39
43
  ```
40
44
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 6.1.0"
5
+ gem "activerecord", "~> 6.1.7.6"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 7.0.0"
5
+ gem "activerecord", "~> 7.0.8"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 6.0.0"
5
+ gem "activerecord", "~> 7.1.1"
6
6
 
7
7
  gemspec path: "../"
@@ -4,11 +4,19 @@ module Postgres
4
4
  module Vacuum
5
5
  class Configuration
6
6
  DEFAULT_LONG_RUNNING_TRANSACTION_THRESHOLD_SECONDS = 5 * 60
7
- attr_accessor :monitor_reporter_class_name, :long_running_transaction_threshold_seconds
7
+ DEFAULT_MONITOR_MAX_RUN_TIME_SECONDS = 10
8
+ DEFAULT_MONITOR_MAX_ATTEMPTS = 1
9
+
10
+ attr_accessor :monitor_reporter_class_name,
11
+ :long_running_transaction_threshold_seconds,
12
+ :monitor_max_run_time_seconds,
13
+ :monitor_max_attempts
8
14
 
9
15
  def initialize
10
16
  self.monitor_reporter_class_name = nil
11
17
  self.long_running_transaction_threshold_seconds = DEFAULT_LONG_RUNNING_TRANSACTION_THRESHOLD_SECONDS
18
+ self.monitor_max_run_time_seconds = DEFAULT_MONITOR_MAX_RUN_TIME_SECONDS
19
+ self.monitor_max_attempts = DEFAULT_MONITOR_MAX_ATTEMPTS
12
20
  end
13
21
  end
14
22
  end
@@ -11,6 +11,14 @@ module Postgres
11
11
  CONNECTION_STATE = 'ConnectionState'
12
12
  CONNECTION_IDLE_TIME = 'ConnectionIdleTime'
13
13
 
14
+ def max_run_time
15
+ Postgres::Vacuum::Monitor.configuration.monitor_max_run_time_seconds.seconds
16
+ end
17
+
18
+ def max_attempts
19
+ Postgres::Vacuum::Monitor.configuration.monitor_max_attempts
20
+ end
21
+
14
22
  def perform(*)
15
23
  with_each_db_name_and_connection do |name, connection|
16
24
  connection.execute(Postgres::Vacuum::Monitor::Query.long_running_transactions).each do |row|
@@ -89,11 +97,7 @@ module Postgres
89
97
  def with_each_db_name_and_connection
90
98
  databases = Set.new
91
99
  ActiveRecord::Base.connection_handler.connection_pools.map do |connection_pool|
92
- db_name = if Postgres::Vacuum::Compatibility.pre_rails_6_1?
93
- connection_pool.spec.config[:database]
94
- else
95
- connection_pool.db_config.configuration_hash[:database]
96
- end
100
+ db_name = connection_pool.db_config.configuration_hash[:database]
97
101
 
98
102
  # activerecord allocates a connection pool per call to establish_connection
99
103
  # multiple pools might interact with the same database so we use the
@@ -3,7 +3,7 @@
3
3
  module Postgres
4
4
  module Vacuum
5
5
  module Monitor
6
- VERSION = '0.14.1'
6
+ VERSION = '0.16.0'
7
7
  end
8
8
  end
9
9
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_record'
4
- require 'postgres/vacuum/compatibility'
5
4
  require 'postgres/vacuum/configuration'
6
5
  require 'postgres/vacuum/monitor/version'
7
6
  require 'postgres/vacuum/monitor/query'
@@ -40,6 +40,6 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency 'rspec_junit_formatter'
41
41
  spec.add_development_dependency 'salsify_rubocop', '~> 1.42.1'
42
42
 
43
- spec.add_dependency 'activerecord', '>= 6.1', '< 7.1'
43
+ spec.add_dependency 'activerecord', '>= 6.1', '< 7.2'
44
44
  spec.add_dependency 'pg', '>= 0.18', '< 2.0'
45
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres-vacuum-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Garces
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-28 00:00:00.000000000 Z
11
+ date: 2023-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '6.1'
132
132
  - - "<"
133
133
  - !ruby/object:Gem::Version
134
- version: '7.1'
134
+ version: '7.2'
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
@@ -141,7 +141,7 @@ dependencies:
141
141
  version: '6.1'
142
142
  - - "<"
143
143
  - !ruby/object:Gem::Version
144
- version: '7.1'
144
+ version: '7.2'
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: pg
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -184,10 +184,9 @@ files:
184
184
  - Rakefile
185
185
  - bin/console
186
186
  - bin/setup
187
- - gemfiles/activerecord_6_0.gemfile
188
187
  - gemfiles/activerecord_6_1.gemfile
189
188
  - gemfiles/activerecord_7_0.gemfile
190
- - lib/postgres/vacuum/compatibility.rb
189
+ - gemfiles/activerecord_7_1.gemfile
191
190
  - lib/postgres/vacuum/configuration.rb
192
191
  - lib/postgres/vacuum/jobs/monitor_job.rb
193
192
  - lib/postgres/vacuum/monitor.rb
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Postgres
4
- module Vacuum
5
- class Compatibility
6
- ACTIVE_RECORD_VERSION = ::Gem::Version.new(::ActiveRecord::VERSION::STRING).release
7
- PRE_RAILS_6_1 = ACTIVE_RECORD_VERSION < ::Gem::Version.new('6.1.0')
8
-
9
- def self.pre_rails_6_1?
10
- PRE_RAILS_6_1
11
- end
12
-
13
- end
14
- end
15
- end