Fixes aiopg hanging or raising psycopg2.OperationalError suddenly in gh-actions CI #2138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Some jobs in our gh-actions CI suddenly experienced long delays or failures as
async def cancel(): self._waiter = create_future(self._loop) self._cancelling = True self._cancellation_waiter = self._waiter > self._conn.cancel() E psycopg2.OperationalError: asynchronous connection attempt underway /opt/hostedtoolcache/Python/3.6.12/x64/lib/python3.6/site-packages/aiopg/connection.py:195: OperationalError
Found a report of a bug in aiopg with similar behaviour caused by problems resolving the hostname.
Noticed that the VM deployed in gh-actions before and after the problem had just been updated. Checking the
/etc/hosts
revealed multiple maps of 127.0.0.1 which might have been a reason why aiopg could not resolve it (again a pr in aiopg to address that problem)What do these changes do?
Replacing localhost by 127.0.0.1 in all settings related with pg hostname
How to test
Run all tests and no more jobs hanging or tests raising OperationalError