Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection.destroy() may kill wrong session (on different node) #304

Open
sergburn opened this issue Jan 21, 2025 · 1 comment
Open

Connection.destroy() may kill wrong session (on different node) #304

sergburn opened this issue Jan 21, 2025 · 1 comment

Comments

@sergburn
Copy link

Current (3.4.0) implementation of connection.destroy() tries to kill ongoing query by opening side connection and executing KILL <thread-id>. It relies on the assumption that this new connection will reach the same server instance if the connection is open by IP rather than DNS.

Quote from connection.js:

        // relying on IP in place of DNS to ensure using same server
        const remoteAddress = this.socket.remoteAddress;
        const connOption = remoteAddress ? Object.assign({}, this.opts, { host: remoteAddress }) : this.opts;

However, if the IP points to a Load Balancer with NAT, this new connection may be opened to another DB instance and then wrong session will be killed.

This behaviour must be optional, please add a corresponding parameter to ConnectionConfig. (I could work on a PR, if wanted)

@sergburn
Copy link
Author

I just realized that threadId is also used to index active connections in pool.js, and thus it's possible that connections open to different servers via load balancer could clash with each other, correct?

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

No branches or pull requests

1 participant