Issue #2364903 by eshta: Implement maximum retry logic for goals queue.