Skip to content

Fix async listener for UNIX domain socket PostgreSQL connections#20744

Merged
zzstoatzz merged 1 commit intomainfrom
devin/1771441135-fix-unix-socket-pg-listener
Feb 18, 2026
Merged

Fix async listener for UNIX domain socket PostgreSQL connections#20744
zzstoatzz merged 1 commit intomainfrom
devin/1771441135-fix-unix-socket-pg-listener

Conversation

@devin-ai-integration
Copy link
Contributor

Fixes the PostgreSQL async LISTEN/NOTIFY connection when using UNIX domain socket connection URLs (e.g. postgresql+asyncpg:///prefect?host=/tmp/.SOSHUB&port=25432).

SQLAlchemy's make_url() places host and port in the query parameters dict for these URLs rather than the standard .host/.port attributes. The existing code only checked the URL authority attributes, so both were None for socket-style URLs, causing the listener connection to fail.

The fix falls back to query params when the standard URL attributes are not set.

Review checklist for humans

  • Verify int(port) cast is safe for both paths: asyncpg_dsn.port (already int) and query.get("port") (returns str). The if port: guard prevents int(None).
  • Consider whether query.get("host") could return a tuple for repeated keys in SQLAlchemy's immutabledict — unlikely but possible edge case.
  • Confirm no other query params (e.g. sslmode) need similar treatment for socket connections.

Closes #20742

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
  • If this pull request adds new functionality, it includes unit tests that cover the changes
  • If this pull request removes docs files, it includes redirect settings in mint.json.
  • If this pull request adds functions or classes, it includes helpful docstrings.

Link to Devin run

https://app.devin.ai/sessions/2a11bbb3200e4b979560213735485e55

Requested by: @zzstoatzz

When using a UNIX domain socket connection URL like:
  postgresql+asyncpg:///prefect?host=/tmp/.SOSHUB&port=25432

SQLAlchemy's make_url() places host and port in query parameters
rather than the standard URL authority section. The pg notify
connection builder now falls back to query params when the standard
URL attributes are None, allowing UNIX socket connections to work.

Closes #20742

Co-Authored-By: Nate Nowack <nate@prefect.io>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions github-actions bot added the bug Something isn't working label Feb 18, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 18, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing devin/1771441135-fix-unix-socket-pg-listener (64ab0e0) with main (0f5c339)

Open in CodSpeed

@zzstoatzz zzstoatzz marked this pull request as ready for review February 18, 2026 20:39
@zzstoatzz zzstoatzz merged commit 6712b8e into main Feb 18, 2026
67 checks passed
@zzstoatzz zzstoatzz deleted the devin/1771441135-fix-unix-socket-pg-listener branch February 18, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Postgres async listener does not work with UNIX domain socket settings

2 participants