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:
copilot-swe-agent[bot]
2026-03-24 13:56:06 +00:00
parent 466f766f04
commit 3be23c9f18
2 changed files with 4 additions and 1 deletions

View File

@@ -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?

View File

@@ -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