backend: fix idempotent retry logic