Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to suppress repetitive logs in development? #658

Closed
sedubois opened this issue Jul 10, 2022 · 3 comments
Closed

How to suppress repetitive logs in development? #658

sedubois opened this issue Jul 10, 2022 · 3 comments

Comments

@sedubois
Copy link

This gets printed every 10 seconds in my development environment:

  GoodJob::Execution Load (0.6ms)  SELECT "good_jobs".* FROM "good_jobs" WHERE "good_jobs"."id" IN (WITH "rows" AS MATERIALIZED ( SELECT "good_jobs"."id", "good_jobs"."active_job_id" FROM "good_jobs" WHERE "good_jobs"."finished_at" IS NULL AND ("good_jobs"."scheduled_at" <= '2022-07-10 08:44:41.505487' OR "good_jobs"."scheduled_at" IS NULL) ORDER BY priority DESC NULLS LAST ) SELECT "rows"."id" FROM "rows" WHERE pg_try_advisory_lock(('x' || substr(md5('good_jobs' || '-' || "rows"."active_job_id"::text), 1, 16))::bit(64)::bigint) LIMIT $1) ORDER BY priority DESC NULLS LAST  [["LIMIT", 1]]
  GoodJob::Lockable Unlock Session (0.2ms)  SELECT pg_advisory_unlock_all()::text AS unlocked

It's mentioned in #455 (comment) that there shouldn't be any polling, however AFAIK I didn't configure anything specific in this regard, here is my initializer:

Rails.application.configure do
  config.good_job.preserve_job_records = true
  config.good_job.retry_on_unhandled_error = false
  config.good_job.on_thread_error = -> (exception) do
    Sentry.set_extras(good_job_on_thread_error: true)
    Sentry.capture_exception(exception)
  end
end

ActionMailer::MailDeliveryJob.retry_on StandardError,
                                       wait: :exponentially_longer, attempts: Float::INFINITY
ActionMailer::MailDeliveryJob.around_perform do |_job, block|
  block.call
rescue StandardError => e
  Sentry.set_extras(action_mailer_standard_error: true)
  Sentry.capture_exception(e)
  raise
end

How can the polling be disabled, or what is otherwise the recommended way to avoid those repetitive logs while developing?

Using Rails 7.0.3, GoodJob 3.0.1.

@bensheldon
Copy link
Owner

That's weird. Can you try running in your console (or puts it after the initializer)

GoodJob::Configuration.new({}).poll_interval

Here's where that's calculated:

def poll_interval
interval = (
options[:poll_interval] ||
rails_config[:poll_interval] ||
env['GOOD_JOB_POLL_INTERVAL']
)
if interval
interval.to_i
elsif Rails.env.development? && execution_mode.in?([:async, :async_all, :async_server])
DEFAULT_DEVELOPMENT_ASYNC_POLL_INTERVAL
else
DEFAULT_POLL_INTERVAL
end
end

@sedubois
Copy link
Author

Okay my mistake, config.good_job.poll_interval = 10 # seconds was defined in application.rb since starting to use GoodJob 2.4.0. Probably a misunderstanding in how to configure GoodJob back then.

@bensheldon
Copy link
Owner

fhew! 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants