Skip to content

Commit

Permalink
fix: Connection lost errors on macos (#64)
Browse files Browse the repository at this point in the history
Postgres connections are dropped when database is running in the host machine.
This solution adds a parameter to SQLAlchemy to ping the database and reconnect if it is dropped.
This is pessimistic and may add latency. However it is the easiest solution.

Refer:
* https://stackoverflow.com/questions/55457069/how-to-fix-operationalerror-psycopg2-operationalerror-server-closed-the-conn
* https://docs.sqlalchemy.org/en/14/core/pooling.html#disconnect-handling-pessimistic

Fix #63
  • Loading branch information
vrajat committed Jul 17, 2021
1 parent 1091e61 commit 49a86e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions .idea/data-lineage.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions data_lineage/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,14 @@ def create_server(
**catalog_options,
connect_args={"application_name": "data-lineage:flask-restless"},
max_overflow=40,
pool_size=20
pool_size=20,
pool_pre_ping=True
)

restful_catalog = Catalog(
**catalog_options, connect_args={"application_name": "data-lineage:restful"}
**catalog_options,
connect_args={"application_name": "data-lineage:restful"},
pool_pre_ping=True
)

app = Flask(__name__)
Expand Down

0 comments on commit 49a86e6

Please sign in to comment.