📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do you handle the commit-in-doubt case when a retrying execution strategy loses the connection during COMMIT?

Intermediate Theory Intermediate

🎯 Key points

  • COMMIT acknowledgement can be lost: the outcome is unknown
  • Blind retry can double-apply the work
  • Unique request id plus a unique index for idempotency
  • ExecuteInTransactionAsync with verifySucceeded checks the database before retrying
  • ChangeTracker.Clear() (or a new context) between attempts
  • Retry only transient errors; permanent errors fail fast
  • Log retries and outcomes (ExecutionStrategyRetrying) for tracing and reconciliation

⏱ 30-second answer

If the connection drops during COMMIT, the client can't know whether the transaction committed, and a blind retry may apply the work twice. Make the unit idempotent (a unique request id checked at the start and enforced by a unique index), or use ExecuteInTransactionAsync with a verifySucceeded delegate that queries the database to see if the work landed before retrying. Clear the change tracker between attempts so stale Added entities aren't re-sent. Only transient errors should be retried: let permanent failures (constraint violations, login failures) surface immediately. Log each retry and its outcome so an in-doubt commit can be traced and reconciled later.

🔍 What the interviewer is checking

Checks understanding of idempotency and verifySucceeded in retried transactions.

↩ Usually asked after

More in Advanced EF Core

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me