Skip to content

Closing PostgreSQL connection deadlocks listen(_:) #601

@billyean

Description

@billyean

Describe the issue

Closing PostgreSQL connection deadlocks listen(_:)

Vapor version

latest

Operating system and version

macOS 26.01

Swift version

Swift 6.2

Steps to reproduce

Reproduction:

  1. The code looks like that:

             try await self.postgresClient.withConnection { connection in
                 148: log.debug("Notifications: Starting listening", metadata: [       
                     "topic": "\(topic)",                                         
                     "psql.conn.id": "\(connection.id)",                          
                     "psql.conn.isClosed": "\(connection.isClosed)"               
                 ])                                                               
                 sequence = try await connection.listen(topic.stringValue)        
                 154: log.debug("Notifications: Now listening", metadata: [            
                     "topic": "\(topic)",                                          
                     "psql.conn.id": "\(connection.id)",                          
                     "psql.conn.isClosed": "\(connection.isClosed)"               
                 ])
    
  2. brew services restart postgresql

  3. The error log similar to the log above gets generated, and the system goes into a deadlock.

Outcome

client goes to infinite waiting

Additional notes

Hash a PR for the fix #600

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions