Entity Framework Core Interview Question #187
How should transient database failures be handled?
Testing, Production Practices & Senior Real-World Scenarios Senior Advanced
Quick Interview Answer
Transient failures are temporary errors such as brief connectivity problems or failovers. Some providers offer execution strategies that retry operations considered transient. Retries must be bounded and should not blindly repeat non-idempotent external side effects. Explicit transactions may need to be executed through the provider's execution strategy as one retriable unit.
Detailed Explanation
Transient failures are temporary errors such as brief connectivity problems or failovers. Some providers offer execution strategies that retry operations considered transient. Retries must be bounded and should not blindly repeat non-idempotent external side effects. Explicit transactions may need to be executed through the provider's execution strategy as one retriable unit.
Code Example
var strategy = db.Database.CreateExecutionStrategy();
await strategy.ExecuteAsync(async () =>
{
// Execute a retry-safe database unit of work.
});