Skip to content

fix: prevent DataContext.Track/Update from cascading to navigation properties#46

Merged
Theauxm merged 1 commit intomainfrom
fix/datacontext-track-graph-cascade
Mar 30, 2026
Merged

fix: prevent DataContext.Track/Update from cascading to navigation properties#46
Theauxm merged 1 commit intomainfrom
fix/datacontext-track-graph-cascade

Conversation

@Theauxm
Copy link
Copy Markdown
Member

@Theauxm Theauxm commented Mar 30, 2026

Summary

  • DataContext.Track/Update used base.Update(model) which traverses the entire entity graph via EF Core's graph walker. When metadata had an eagerly-loaded Manifest (from LoadMetadataJunction.Include(x => x.Manifest)), the Manifest was marked Modified, generating unnecessary UPDATE trax.manifest statements that caused lock contention with MetadataCleanupTrain's long-running DELETE — hanging Lambda workers on dormant dependent trains indefinitely.
  • Replaced base.Update(model) with direct entry.State assignment, which only affects the target entity without traversing navigations. Preserves the same key heuristic (Id > 0 → Modified, Id == 0 → Added).
  • Fixed EffectRunner.Track/Update to properly await RunAllAsync instead of fire-and-forget via sync RunAll. All current providers are synchronous so this was latent, but prevents future async providers from silently failing.

Test plan

  • 2 new navigation-isolation tests: Track/Update with loaded Manifest verify the Manifest stays Detached
  • 2 new async-aware tests: EffectRunner.Track/Update properly await providers with Task.Yield()
  • All 69 InMemory integration tests pass
  • All 362 Trax.Effect tests pass
  • CSharpier formatted, zero warnings in modified code

…operties

DataContext.Track and Update used base.Update(model) which traverses
the entire entity graph, marking loaded navigation properties (like
Manifest) as Modified. This generated unnecessary UPDATE statements
that caused lock contention with MetadataCleanupTrain, hanging Lambda
workers on dormant dependent trains.

Replace with direct entry.State assignment which only affects the
target entity. Also fix EffectRunner.Track/Update to properly await
async provider calls (was fire-and-forget via sync RunAll).
@Theauxm Theauxm merged commit 3e127bb into main Mar 30, 2026
1 check passed
@Theauxm Theauxm deleted the fix/datacontext-track-graph-cascade branch March 30, 2026 17:34
@traxsharp
Copy link
Copy Markdown

traxsharp Bot commented Mar 30, 2026

This PR is included in version 1.28.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant