feat(sync): --refresh-destination-state-before-apply flag#618
Merged
Conversation
Opt-in destination-state refresh from storage before apply_resources dispatches workers. Insert-if-absent semantics; in-flight writes are preserved. Off by default. For orchestrators running sync-cli once per resource type against shared state. Co-Authored-By: Claude Opus 4.7 <[email protected]>
riyazsh
force-pushed
the
riyaz/HAMR-392-phase-state-load-race
branch
from
July 9, 2026 15:44
f850d1f to
64530da
Compare
nathantournant
previously approved these changes
Jul 9, 2026
heyronhay
previously approved these changes
Jul 9, 2026
# Conflicts: # datadog_sync/utils/resources_handler.py
heyronhay
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New opt-in flag on
syncandmigrate:--refresh-destination-state-before-apply(defaultFalse)When set,
apply_resourcesre-reads the destination side of the storage backend for the resource types in scope, right before workers dispatch. Insert-if-absent — in-flight writes from the current process are preserved.Why
When an orchestrator runs sync-cli once per resource type as separate processes against a shared storage backend, an earlier process can write destination blobs AFTER a later process loaded state at startup. The later process's dependency lookups (
connect_resources) then miss ids that are on disk but not in memory.The refresh picks up those late-arriving blobs. Failure to refresh logs a warning and proceeds with the pre-refresh state; apply never aborts.
Off by default
Single-process users don't have this race and shouldn't pay the refresh cost.
Test plan
pytest tests/unit/— 816 passing (6 new).