On one of our legacy systems we receive this error message from libpq driver of postgresql. It happens at random times for any of our SQL statements.
psql query begin returned PGRES_FATAL_ERROR - could not receive data from server: Bad file descriptor
The library versions are:
postgresql-10/now 10.18-1.pgdg90+1 amd64 [installed,upgradable to: 10.22-1.pgdg90+1]
postgresql-client-10/now 10.18-1.pgdg90+1 amd64 [installed,upgradable to: 10.22-1.pgdg90+1]
postgresql-client-common/now 231.pgdg90+1 all [installed,upgradable to: 242.pgdg90+1]
postgresql-common/now 231.pgdg90+1 all [installed,upgradable to: 242.pgdg90+1]
libpq5/now 14.0-1.pgdg90+1 amd64 [installed,upgradable to: 14.5-1.pgdg90+1]