# Argo CD sync window race condition can cause database migration hooks to be skipped

> **Key takeaway:** A race condition between different refresh types in Argo CD can cause automated self-healing to skip Sync hooks during a sync window closure.

**Published:** 2026-11-20T12:30:00+00:00 
**Source:** Cloud Native Computing Foundation (CNCF) 
**Category:** cloud-native 
**Canonical URL:** https://fosswire.org/news/argo-cd-sync-window-race-condition-can-cause-database-migrat.html 

## Summary
A technical investigation by CNCF Ambassador Afzal Ansari has identified a race condition in Argo CD that can lead to failed software deployments. When a 'deny sync window' closes, the timing of the next application refresh determines whether a full sync or a partial self-heal occurs. If a level-1 refresh occurs before a timer-driven level-2 refresh, the controller may incorrectly conclude that the application is already synchronized with the target revision.

This behavior is particularly dangerous because the Argo CD UI reports the application as 'Synced' and 'Healthy,' even if critical Sync hooks—such as database migrations—were never executed. The issue stems from how the controller handles drift correction versus full synchronization, leading to a state where new application code runs against an outdated database schema.

## The mechanics of the Argo CD refresh race
- **Refresh Types:** Argo CD utilizes two refresh paths: level-1 refreshes (triggered by managed object changes) and level-2 refreshes (triggered by a periodic reconciliation timer).
- **The Race Condition:** If a level-1 refresh arrives immediately after a sync window opens, it compares the current revision against itself and concludes no changes are needed, triggering a 'self-heal' of drifted resources rather than a full sync.
- **Hook Bypass:** Because self-healing is technically a partial sync of out-of-sync resources, the controller skips all Sync hooks, including those annotated with `argocd.argoproj.io/hook: Sync`.
- **Recommended Mitigation:** Instead of relying on hooks, engineers should include migration Jobs as managed resources with unique names per release and utilize `argocd.argoproj.io/sync-wave` to ensure they execute before the main application deployment.

## Why it matters
This finding highlights a critical reliability risk for DevOps engineers using GitOps workflows for stateful applications. It demonstrates that Sync hooks should not be treated as guarantees for critical operations like schema migrations, necessitating a shift toward treating migrations as part of the desired state via sync waves.