gouda 0.1.10 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 194787c234288ffdeede62d80c4b4bb2fc32f9fc14dff756176ce1962ebacd99
4
- data.tar.gz: 2c02e284e17e80640c279057c66afcbd34d40ccac3ab730a59572c21562c0430
3
+ metadata.gz: 5b26bf19a2b7e37c30fe63354512873c56dc8784b97acf7b3f56bebc9358db71
4
+ data.tar.gz: cdeee22468899bfd3bcf8ff6914e1b8ff67a9a23f12c1613df51cce8c7b18393
5
5
  SHA512:
6
- metadata.gz: 52ded3cb575eedb5392d51cfe9a358d4a76792a65c3764bbf7ad091c5d17740cfdb7429278a8389abb15533ff97298810e954595c5d7621044e7d6bf2e728f60
7
- data.tar.gz: 4df3f4ab5d53ef0acbf4c9be87500e6c64e2333444035de113337822894b7ab414b68970a6f6c4194c65a1042ab4f4f86276aec7b4ab48ea1a46b1c8ad67c56f
6
+ metadata.gz: 59c31a696c8e64ba06af1f8b5eedaed7d9aec0dbc76130e6797bdd76badedf37f82a6a0c582686483b855211ed157ee25096689deb347cda44e4af896cf7b5dc
7
+ data.tar.gz: 8ed39bae53908ebfd1d6f48ad3fb99e0eef6c2cd922a9df4bc42e3a3e8059dfc8e996d240bc593cb5087025ae29d634c5f021997db67d9c63131bedac422abf2
data/CHANGELOG.md CHANGED
@@ -47,4 +47,12 @@
47
47
 
48
48
  ## [0.1.10] - 2024-07-03
49
49
 
50
- - Fix: remove logger overrides that Gouda should install, as this causes problems for Rails apps hosting Gouda
50
+ - Fix: remove logger overrides that Gouda should install, as this causes problems for Rails apps hosting Gouda
51
+
52
+ ## [0.1.11] - 2024-07-03
53
+
54
+ - Fix: make sure the Gouda logger config does not get used during Rails initialization
55
+
56
+ ## [0.1.12] - 2024-07-03
57
+
58
+ - When doing polling, suppress DEBUG-level messages. This will stop Gouda spamming the logs with SQL in dev/test environments.
data/lib/gouda/railtie.rb CHANGED
@@ -43,14 +43,10 @@ module Gouda
43
43
  Gouda.config.preserve_job_records = config_from_rails[:preserve_job_records]
44
44
  Gouda.config.polling_sleep_interval_seconds = config_from_rails[:polling_sleep_interval_seconds]
45
45
  Gouda.config.worker_thread_count = config_from_rails[:worker_thread_count]
46
- if Gouda.config.logger
47
- Gouda.config.logger.level = config_from_rails[:log_level] || Gouda.config.log_level
48
- end
49
46
  end
50
47
  else
51
48
  Gouda.config.preserve_job_records = false
52
49
  Gouda.config.polling_sleep_interval_seconds = 0.2
53
- Gouda.config.logger.level = Gouda.config.log_level
54
50
  end
55
51
 
56
52
  Gouda::Scheduler.build_scheduler_entries_list!
data/lib/gouda/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gouda
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.12"
5
5
  end
data/lib/gouda/worker.rb CHANGED
@@ -83,12 +83,13 @@ module Gouda
83
83
  end
84
84
 
85
85
  def call
86
- # return false unless Rails.application # Rails is still booting and there is no application defined
87
-
88
86
  Gouda.config.app_executor.wrap do
89
- Gouda::Workload.waiting_to_start(queue_constraint: @queue_constraint).none?
87
+ Gouda.suppressing_sql_logs { Gouda::Workload.waiting_to_start(queue_constraint: @queue_constraint).none? }
90
88
  end
91
- rescue # If the DB connection cannot be checked out etc
89
+ rescue
90
+ # It is possible that in this scenario we do not have a database set up yet, for example,
91
+ # or we are unable to connect to the DB for whatever reason. In that case we should
92
+ # return `false` so that the worker can poll again later.
92
93
  false
93
94
  end
94
95
  end
@@ -158,13 +159,14 @@ module Gouda
158
159
  # a stale timestamp can indicate to us that the job was orphaned and is marked as "executing"
159
160
  # even though the worker it was running on has failed for whatever reason.
160
161
  # Later on we can figure out what to do with those jobs (re-enqueue them or toss them)
161
- Gouda::Workload.where(id: executing_workload_ids.to_a, state: "executing").update_all(executing_on: worker_id, last_execution_heartbeat_at: Time.now.utc)
162
+ Gouda.suppressing_sql_logs do # these updates will also be very frequent with long-running jobs
163
+ Gouda::Workload.where(id: executing_workload_ids.to_a, state: "executing").update_all(executing_on: worker_id, last_execution_heartbeat_at: Time.now.utc)
164
+ end
162
165
 
163
166
  # Find jobs which just hung and clean them up (mark them as "finished" and enqueue replacement workloads if possible)
164
167
  Gouda::Workload.reap_zombie_workloads
165
168
  rescue => e
166
169
  Gouda.instrument(:exception, {exception: e})
167
-
168
170
  warn "Uncaught exception during housekeeping (#{e.class} - #{e}"
169
171
  end
170
172
 
@@ -115,9 +115,9 @@ class Gouda::Workload < ActiveRecord::Base
115
115
  payload[:retried_checkouts_due_to_concurrent_exec] = 0
116
116
  uncached do # Necessary because we SELECT with a clock_timestamp() which otherwise gets cached by ActiveRecord query cache
117
117
  transaction do
118
- jobs.first.tap do |job|
119
- job&.update!(state: "executing", executing_on: executing_on, last_execution_heartbeat_at: Time.now.utc, execution_started_at: Time.now.utc)
120
- end
118
+ job = Gouda.suppressing_sql_logs { jobs.first } # Silence SQL output as this gets called very frequently
119
+ job&.update!(state: "executing", executing_on: executing_on, last_execution_heartbeat_at: Time.now.utc, execution_started_at: Time.now.utc)
120
+ job
121
121
  rescue ActiveRecord::RecordNotUnique
122
122
  # It can happen that due to a race the `execution_concurrency_key NOT IN` does not capture
123
123
  # a job which _just_ entered the "executing" state, apparently after we do our SELECT. This will happen regardless
data/lib/gouda.rb CHANGED
@@ -81,6 +81,20 @@ module Gouda
81
81
  Rails.try(:logger) || ActiveJob::Base.try(:logger) || @fallback_gouda_logger
82
82
  end
83
83
 
84
+ def self.suppressing_sql_logs(&blk)
85
+ # This is used for frequently-called methods that poll the DB. If logging is done at a low level (DEBUG)
86
+ # those methods print a lot of SQL into the logs, on every poll. While that is useful if
87
+ # you collect SQL queries from the logs, in most cases - especially if this is used
88
+ # in a side-thread inside Puma - the output might be quite annoying. So silence the
89
+ # logger when we poll, but just to INFO. Omitting DEBUG-level messages gets rid of the SQL.
90
+ if Gouda::Workload.logger
91
+ Gouda::Workload.logger.silence(Logger::INFO, &blk)
92
+ else
93
+ # In tests (and at earlier stages of the Rails boot cycle) the global ActiveRecord logger may be nil
94
+ yield
95
+ end
96
+ end
97
+
84
98
  def self.instrument(channel, options, &block)
85
99
  ActiveSupport::Notifications.instrument("#{channel}.gouda", options, &block)
86
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gouda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian van Hesteren