Description
The current session synchronization flow only fetches sessions with syncStatus = 'PENDING'.
This causes failed sessions to be permanently excluded from future synchronization attempts.
Current behavior
PENDING → Sync attempt → Server/Network error → FAILED
↓
Excluded from future syncs
The DAO query currently uses:
WHERE syncStatus = 'PENDING'
So even if WorkManager returns Result.retry(), the next synchronization attempt will not pick up sessions that are already marked as FAILED.
Expected behavior
Failed sessions should remain eligible for future synchronization attempts.
A minimal solution would be:
WHERE syncStatus IN ('PENDING', 'FAILED')
A more robust retry mechanism could also track:
failureCount
nextRetryAt
lastError
lastAttemptAt
This would allow the synchronization system to implement controlled retries, such as exponential backoff, instead of retrying failed sessions indefinitely or immediately.
Impact
Currently, a temporary server or network failure can cause a session to become permanently unsynchronized unless it is manually reset to PENDING.
This can result in permanent data loss from the backend.
Suggested solution
Implement retryable synchronization for failed sessions, preferably with retry metadata and backoff handling.
Description
The current session synchronization flow only fetches sessions with
syncStatus = 'PENDING'.This causes failed sessions to be permanently excluded from future synchronization attempts.
Current behavior
The DAO query currently uses:
So even if
WorkManagerreturnsResult.retry(), the next synchronization attempt will not pick up sessions that are already marked asFAILED.Expected behavior
Failed sessions should remain eligible for future synchronization attempts.
A minimal solution would be:
A more robust retry mechanism could also track:
failureCountnextRetryAtlastErrorlastAttemptAtThis would allow the synchronization system to implement controlled retries, such as exponential backoff, instead of retrying failed sessions indefinitely or immediately.
Impact
Currently, a temporary server or network failure can cause a session to become permanently unsynchronized unless it is manually reset to
PENDING.This can result in permanent data loss from the backend.
Suggested solution
Implement retryable synchronization for failed sessions, preferably with retry metadata and backoff handling.