OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
retry job twice and then discard if job limit is exceeded
ulferts4335f30b67c3
diff --git a/app/workers/cron/quarter_hour_schedule_job.rb b/app/workers/cron/quarter_hour_schedule_job.rbindex 822b9cae29d..dc4cc9e66eb 100644--- a/app/workers/cron/quarter_hour_schedule_job.rb+++ b/app/workers/cron/quarter_hour_schedule_job.rb@@ -40,6 +40,13 @@ module Cron::QuarterHourScheduleJobenqueue_limit: 1,perform_limit: 1)++ # The job is scheduled to run every 15 minutes. If the job before takes longer+ # than expected we retry two more times (at cron_at + 5 and cron_at + 15). Then the job is discarded.+ # Once the job is discarded, the next job will be scheduled to run at the next quarter hour.+ retry_on GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError,+ wait: 5.minutes,+ attempts: 3endprivatediff --git a/spec/features/notifications/reminder_mail_spec.rb b/spec/features/notifications/reminder_mail_spec.rbindex 06f6364a7b8..d2e8dbde9f0 100644--- a/spec/features/notifications/reminder_mail_spec.rb+++ b/spec/features/notifications/reminder_mail_spec.rb@@ -1,7 +1,7 @@require "spec_helper"require_relative "../users/notifications/shared_examples"-RSpec.describe "Reminder email sending", :js, :with_cuprite do+RSpec.describe "Reminder email sending", js: false dolet!(:project) { create(:project, members: { current_user => role }) }let!(:mute_project) { create(:project, members: { current_user => role }) }let(:role) { create(:project_role, permissions: %i[view_work_packages]) }@@ -9,17 +9,26 @@ RSpec.describe "Reminder email sending", :js, :with_cuprite dolet(:work_package) { create(:work_package, project:) }let(:watched_work_package) { create(:work_package, project:, watcher_users: [current_user]) }let(:involved_work_package) { create(:work_package, project:, assigned_to: current_user) }- # ApplicationJob#job_scheduled_at is used for scheduling the reminder mails- # needs to be within a time frame eligible for sending out mails for the chose- # time zone. For the time zone Hawaii (UTC-10) this means between 8:00:00 and 8:14:59 UTC.- # The job is scheduled to run every 15 min so the scheduled_at will in production always move between the quarters of an hour.- # The current time can be way behind that.- let(:current_utc_time) { ActiveSupport::TimeZone["Pacific/Honolulu"].parse("2021-09-30T08:34:10").utc }+ # GoodJob::Job#cron_at is used for scheduling the reminder mails.+ # It needs to be within a time frame eligible for sending out mails for the chosen+ # time zone. For the time zone Hawaii (UTC-10) this means 8:00:00 as the job has a cron tab to be run every 15 min.let(:job_run_at) { ActiveSupport::TimeZone["Pacific/Honolulu"].parse("2021-09-30T08:00:00").utc }- # Fix the time of the specs to ensure a consistent run+ let(:scheduled_job) do+ Notifications::ScheduleReminderMailsJob.perform_later.tap do |job|+ GoodJob::Job+ .where(id: job.job_id)+ .update_all(cron_at: job_run_at)+ end+ end++ # The reminder mail is sent out after notifications have been created which might have happened way earlier.+ # This spec will be fixed to this time ensure a consistent run and to mimic the time that typically has passed+ # between the changes to a work package and the reminder mail being sent out.+ let(:work_package_update_time) { ActiveSupport::TimeZone["Pacific/Honolulu"].parse("2021-09-30T01:50:34").utc }+around do |example|- Timecop.travel(current_utc_time) do+ Timecop.travel(work_package_update_time) doexample.runendend@@ -31,7 +40,7 @@ RSpec.describe "Reminder email sending", :js, :with_cuprite dotime_zone: "Pacific/Honolulu",daily_reminders: {enabled: true,- times: [hitting_reminder_slot_for("Pacific/Honolulu", current_utc_time)]+ times: [hitting_reminder_slot_for("Pacific/Honolulu", job_run_at)]},immediate_reminders: {mentioned: false@@ -59,8 +68,7 @@ RSpec.describe "Reminder email sending", :js, :with_cuprite doActiveJob::Base.disable_test_adapter- scheduled_job = Notifications::ScheduleReminderMailsJob.perform_later- GoodJob::Job.where(id: scheduled_job.job_id).update_all(scheduled_at: job_run_at)+ scheduled_jobendit "sends a digest mail based on the configuration", with_settings: { journal_aggregation_time_minutes: 0 } do