Getting issue while looping same test case in case of failure

No problem and apologies I miss understood, I believe this question of some sort has been asked a few times on the forum, just searching and taking the first result which might be helpful in answering your question or a start in the right direction:

Personally not done this myself using the test:retry(value), but seems fairly straightforward