gouda 0.1.11 → 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: 9b4b5340ec99f15fe7a62bc9a63642862219dc149d38d2e7e519f2ed655747e0
4
- data.tar.gz: 817fe1a0ef4a2b107ad07ce28c3e627e79ffe3cf5fb1be06089165e07e432ec5
3
+ metadata.gz: 5b26bf19a2b7e37c30fe63354512873c56dc8784b97acf7b3f56bebc9358db71
4
+ data.tar.gz: cdeee22468899bfd3bcf8ff6914e1b8ff67a9a23f12c1613df51cce8c7b18393
5
5
  SHA512:
6
- metadata.gz: 0aa57b5dedc0a7fe3126d965fe377ebb00dc8f407d7a01877886b57c2f35f45bd2c254d370949a65ec44f3704353b2741509ff099acc0c285aa752ab500805a1
7
- data.tar.gz: 29f6d58da6179f0af817c541fdf9e0ca2fbf00fa83cab2d69c780a221761b26d08679a02419afbba93070d7d19babed436727a2cf994471fa94aabf7c359a7b8
6
+ metadata.gz: 59c31a696c8e64ba06af1f8b5eedaed7d9aec0dbc76130e6797bdd76badedf37f82a6a0c582686483b855211ed157ee25096689deb347cda44e4af896cf7b5dc
7
+ data.tar.gz: 8ed39bae53908ebfd1d6f48ad3fb99e0eef6c2cd922a9df4bc42e3a3e8059dfc8e996d240bc593cb5087025ae29d634c5f021997db67d9c63131bedac422abf2
data/CHANGELOG.md CHANGED
@@ -52,3 +52,7 @@
52
52
  ## [0.1.11] - 2024-07-03
53
53
 
54
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/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gouda
4
- VERSION = "0.1.11"
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.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian van Hesteren