Skip to content

Pool cancel query #2261

@beeing

Description

@beeing

Hi, I noticed there are few attempts to add cancel to client, pool, etc.

As of now I believe there's no full-proof solution yet.

However, just wondering if it is possible that I can add my own hack to get this working?

There are some long-running queries which if the user aborts (like request.on('close')),
I can cancel the long running query to prevent the server from becoming blocking and also improve server's CPU utilisation.

My initial idea is that can I run SELECT pg_backend_pid() before running the actual query and the pg_cancel_backend when request is closed. But since this is in pool, each query will be using the available connection which may lead to a wrong pid.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions