• Yorick Peterse's avatar
    Catch errors in LoadBalancing::Host#online? · 2648d6de
    Yorick Peterse authored
    Prior to this commit it was possible for Host#online? to raise a
    connection error when checking an already offline host. This could
    happen because certain methods used for checking if a host is available
    call the "connection" method, without catching any errors. As a result,
    if this method raises then #online? would also raise. All of this could
    lead to GitLab becoming unavailable depending on how many times it would
    try to use this offline host.
    
    To work around this we catch the errors that might be raised in
    Host#online?. Unlike the code in LoadBalancing::LoadBalancer we don't
    need to catch individual PG errors as we don't have to worry about
    application errors. This means we only have to catch up to three errors:
    
    1. ActionView::Template::Error (used inside views).
    
    2. ActiveRecord::StatementInvalid (used basically everywhere outside of
       views).
    
    3. PG::Error: used in some rare cases where Rails (for reasons unknown)
       doesn't wrap the original error.
    2648d6de
load-balancer-connection-bug.yml 90 Bytes