mirror of
https://github.com/we-promise/sure.git
synced 2026-05-07 12:54:04 +00:00
Polish sync retry handling comments and assertions
Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> Agent-Logs-Url: https://github.com/we-promise/sure/sessions/ea7a06f4-8344-4a00-877a-eda8cdfdc16a
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user