npgsql: Determining if connection pool was exhausted based on exception

Hi, what I’m trying to achieve is to change my web app to start returning 503 status code (Service Unavailable) when exception related to exceeding connection pool is thrown. Is there a way to unequivocally qualify exception that is thrown in such situation? From what I can see it is NpgsqlException with IsTransient equal true and InnerException as TimeoutException. However I’m not sure if there aren’t any other scenarios when exception with such configuration could be thrown but from a different reason. Parsing exception msg is not an approach that I want to follow.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Submitted #4580, implementation can be discussed there.

(if you don’t hear back in a week or two, please feel free to ping me here again)

Thanks for the extra context, I understand.

Let us have a quick internal discussion about this; #1072 implies a bit of design thinking before we actually implement. There’s also the option of providing this via a specific exception class (e.g. NpgsqlPoolExhaustionException) instead of a code - we need to think about all that a bit.