Skip to content
This repository was archived by the owner on Jan 4, 2024. It is now read-only.
This repository was archived by the owner on Jan 4, 2024. It is now read-only.

Database server closed connection error when using parallel processing #65

@mactyr

Description

@mactyr

While doing a full model run with parallel processing enabled, I encountered the error below (and verified it by running a second time). It does not appear to be a problem related to my maximum connections since postgres' max_connections is set to 100 and I only had one run going (which shouldn't spawn any more connections than the number of cores). When I run with parallel processing disabled I do not get the error.

I have googled this and while I haven't been able to find the exact issue, this sort of error does seem to be associated with parallel processing; in particular, people have reported it happening when a process opens a connection, then forks, then one of the child processes closes the connection before the other is done using it. See here, which helpfully links to here.

As far as I know I am the only one to have encountered this error so far, but given that it's parallel processing related it's not surprising that it would vary across OSes/machines/etc.

Stack trace:

[...snip...]
calculating supply-side prior to current year
Traceback (most recent call last):
  File "main.py", line 58, in <module>
    model.calculate_supply()
  File "/Users/michael/Documents/Pathways/energyPATHWAYS/energyPATHWAYS/energyPATHWAYS.py", line 129, in calculate_supply
    self.supply.initial_calculate()     
  File "/Users/michael/Documents/Pathways/energyPATHWAYS/energyPATHWAYS/supply.py", line 183, in initial_calculate
    self.calculate_initial_demand()    
  File "/Users/michael/Documents/Pathways/energyPATHWAYS/energyPATHWAYS/supply.py", line 2082, in calculate_initial_demand
    self.map_demand_to_io()
  File "/Users/michael/Documents/Pathways/energyPATHWAYS/energyPATHWAYS/supply.py", line 2196, in map_demand_to_io
    map_dict = dict(util.sql_read_table('SupplyNodes',['final_energy_link','id']))
  File "/Users/michael/Documents/Pathways/energyPATHWAYS/energyPATHWAYS/util.py", line 186, in sql_read_table
    config.cfg.cur.execute(query)
psycopg2.OperationalError: server closed the connection unexpectedly
  This probably means the server terminated abnormally before or while processing the request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions