diff --git a/app/models/sync.rb b/app/models/sync.rb index 0cb529577..ba19bac01 100644 --- a/app/models/sync.rb +++ b/app/models/sync.rb @@ -105,6 +105,8 @@ class Sync < ApplicationRecord def fail_for_retry_exhaustion!(error_message) Sync.transaction do lock! + # Retry exhaustion can leave the sync in `pending` because we reset it + # after each rate-limit error to make the next ActiveJob retry retryable. start! if pending? fail! if may_fail? update!(error: error_message) @@ -118,9 +120,9 @@ class Sync < ApplicationRecord Sync.transaction do lock! + return if pending? # If this is the "parent" and there are still children running, don't finalize. return unless all_children_finalized? - return if pending? if syncing? if has_failed_children? diff --git a/test/models/sync_test.rb b/test/models/sync_test.rb index 3393940da..ecb78f816 100644 --- a/test/models/sync_test.rb +++ b/test/models/sync_test.rb @@ -59,6 +59,7 @@ class SyncTest < ActiveSupport::TestCase sync.reload assert_equal "pending", sync.status assert_nil sync.error + assert_not_nil sync.pending_at assert_nil sync.syncing_at assert_nil sync.failed_at assert_nil sync.completed_at