Skip to content

Infinite loop in DB load balancer retry logic

When doing a DB read, we rescue connection errors and retry:

https://gitlab.com/gitlab-org/gitlab/blob/28ea4ecc01a9bb313a7f125e0737b95dcafc1d28/lib/gitlab/database/load_balancing/load_balancer.rb#L47-99

When an instance has no secondaries configured, the LB host list is just HostList.new([PrimaryHost.new(self)]) and the primary can never be marked as offline: https://gitlab.com/gitlab-org/gitlab/blob/9599f8669a9395d5193be1b226b4c136f28f8e90/lib/gitlab/database/load_balancing/primary_host.rb#L51-57

So it will just continue to loop inside the while. I think we should add a max retries here.

Follow-ups:

Edited by Thong Kuah