Skip to content

fix: add pg8000 graceful shutdown on Cloud Run scale-down#270

Open
panish16 wants to merge 8 commits into
bcgov:mainfrom
panish16:fix/pg8000-graceful-shutdown
Open

fix: add pg8000 graceful shutdown on Cloud Run scale-down#270
panish16 wants to merge 8 commits into
bcgov:mainfrom
panish16:fix/pg8000-graceful-shutdown

Conversation

@panish16
Copy link
Copy Markdown
Contributor

@panish16 panish16 commented May 27, 2026

Summary

  • Adds _setup_pg8000_graceful_shutdown to doc-api/create_app() to suppress pg8000.exceptions.InterfaceError during Cloud Run scale-down
  • doc-api connects via Unix socket (not Cloud SQL Connector), so the listener is implemented inline with a driver == "pg8000" guard
  • Fixes the error pattern last seen in doc-api-dev on 2026-05-14

Services fixed

  • document-service/doc-api/src/doc_api/init.py

Test plan

  • Confirm no new pg8000.exceptions.InterfaceError entries in GCP Log Explorer for c4hnrd-prod project after deployment
  • Existing unit and integration test suites pass

panish16 added 8 commits May 26, 2026 16:42
Calls setup_pg8000_close_event_listener(engine) after db init in notify-api
and notify-delivery so pg8000 InterfaceError is suppressed instead of logged
as an error when SQLAlchemy closes pooled connections during teardown.

Resolves #33564
Covers all branches of _setup_pg8000_graceful_shutdown:
non-pg8000 early return, listener registration, normal close,
InterfaceError suppression, re-raise of other errors,
and ImportError fallback. Also renames _InterfaceError to
_interface_error to satisfy naming linter rules.
…n doc-api

Replace local _setup_pg8000_graceful_shutdown copy with the shared
setup_pg8000_close_event_listener from sbc-connect-common/cloud-sql-connector
(main branch, v0.2.3). Matches the approach used by notify-api,
notify-delivery, and the lear queue services.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant