sidorares / sidorares/node-mysql2

mysql2 query to proxysql hangs

Open
#656 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

Using nodejs 8.7.0, mysql2 1.4.2 and proxysql 1.4.3 queries are hanging.

All on Ubuntu 16.04.

If we test the same setup with mysql against proxysql, we get the expected result.

We have made a simple test case:

var mysql = require('mysql2')

var config = {
  host: 'dev-db',
  user: 'bob',
  password: 'alice',
  database: 'spiddb',
  port: 6033,
  supportBigNumbers: true,
  timezone: 'Z'
}

var main = function () {
  try {
    const db = mysql.createConnection(config)
    db.query('SELECT * from testtable;', function (err, rows, fields) {
      if (err) {
        console.log(err)
      } else {
        console.log('rows => ', rows)
        db.close()
      }
    })
  } catch (err) {
    console.log(err)
  }
}

main()

Changing "mysql2" to "mysql" and port from "3306" (mysql) to "6033" (proxysql) yields the following results:
mysql and 3306 success
mysql2 and 3306 success
mysql and 6033 success
mysql2 and 6033 fail (hangs)

This is a tcpdump of mysql2 to proxysql:

10:15:56.196138 IP dev-db.6033 > dev-app.50548: Flags [.], ack 70, win 227, options [nop,nop,TS val 64120310 ecr 64119311], length 0
	0x0000:  4500 0034 17ac 4000 4006 ac78 c0a8 7a73  E..4..@.@..x..zs
	0x0010:  c0a8 7adb 1791 c574 cfc7 72a6 c944 6321  ..z....t..r..Dc!
	0x0020:  8010 00e3 76c6 0000 0101 080a 03d2 65f6  ....v.........e.
	0x0030:  03d2 620f                                ..b.

10:15:56.196378 IP dev-db.6033 > dev-app.50548: Flags [P.], seq 79:90, ack 70, win 227, options [nop,nop,TS val 64120310 ecr 64119311], length 11
	0x0000:  4500 003f 17ad 4000 4006 ac6c c0a8 7a73  E..?..@.@..l..zs
	0x0010:  c0a8 7adb 1791 c574 cfc7 72a6 c944 6321  ..z....t..r..Dc!
	0x0020:  8018 00e3 76d1 0000 0101 080a 03d2 65f6  ....v.........e.
	0x0030:  03d2 620f 0700 0002 0000 0000 0000 00    ..b............

10:15:56.197087 IP dev-app.50548 > dev-db.6033: Flags [P.], seq 70:99, ack 90, win 229, options [nop,nop,TS val 64119312 ecr 64120310], length 29
	0x0000:  4500 0051 00da 4000 4006 c32d c0a8 7adb  E..Q..@.@..-..z.
	0x0010:  c0a8 7a73 c574 1791 c944 6321 cfc7 72b1  ..zs.t...Dc!..r.
	0x0020:  8018 00e5 76e3 0000 0101 080a 03d2 6210  ....v.........b.
	0x0030:  03d2 65f6 1900 0000 0353 454c 4543 5420  ..e......SELECT.
	0x0040:  2a20 6672 6f6d 2074 6573 7474 6162 6c65  *.from.testtable
	0x0050:  3b                                       ;

10:15:56.235722 IP dev-db.6033 > dev-app.50548: Flags [.], ack 99, win 227, options [nop,nop,TS val 64120320 ecr 64119312], length 0
	0x0000:  4500 0034 17ae 4000 4006 ac76 c0a8 7a73  E..4..@.@..v..zs
	0x0010:  c0a8 7adb 1791 c574 cfc7 72b1 c944 633e  ..z....t..r..Dc>
	0x0020:  8010 00e3 76c6 0000 0101 080a 03d2 6600  ....v.........f.
	0x0030:  03d2 6210                                ..b.

This is a tcpdump of mysql to proxysql:

10:14:32.309504 IP dev-app.50544 > dev-db.6033: Flags [P.], seq 70:99, ack 90, win 229, options [nop,nop,TS val 64098340 ecr 64099338], length 29
	0x0000:  4500 0051 31c7 4000 4006 9240 c0a8 7adb  E..Q1.@.@..@..z.
	0x0010:  c0a8 7a73 c570 1791 d6d0 2226 a15a 2e09  ..zs.p...."&.Z..
	0x0020:  8018 00e5 76e3 0000 0101 080a 03d2 1024  ....v..........$
	0x0030:  03d2 140a 1900 0000 0353 454c 4543 5420  .........SELECT.
	0x0040:  2a20 6672 6f6d 2074 6573 7474 6162 6c65  *.from.testtable
	0x0050:  3b                                       ;

10:14:32.310154 IP dev-db.6033 > dev-app.50544: Flags [P.], seq 90:173, ack 99, win 227, options [nop,nop,TS val 64099338 ecr 64098340], length 83
	0x0000:  4500 0087 39bc 4000 4006 8a15 c0a8 7a73  E...9.@.@.....zs
	0x0010:  c0a8 7adb 1791 c570 a15a 2e09 d6d0 2243  ..z....p.Z...."C
	0x0020:  8018 00e3 7719 0000 0101 080a 03d2 140a  ....w...........
	0x0030:  03d2 1024 0100 0001 0132 0000 0203 6465  ...$.....2....de
	0x0040:  6606 7370 6964 6462 0974 6573 7474 6162  f.spiddb.testtab
	0x0050:  6c65 0974 6573 7474 6162 6c65 0269 6402  le.testtable.id.
	0x0060:  6964 0c3f 000b 0000 0003 0080 0000 0005  id.?............
	0x0070:  0000 03fe 0000 2200 0200 0004 0131 0500  ......"......1..
	0x0080:  0005 fe00 0022 00                        .....".

10:14:32.315155 IP dev-app.50544 > dev-db.6033: Flags [F.], seq 99, ack 173, win 229, options [nop,nop,TS val 64098341 ecr 64099338], length 0
	0x0000:  4500 0034 31c8 4000 4006 925c c0a8 7adb  E..41.@.@..\..z.
	0x0010:  c0a8 7a73 c570 1791 d6d0 2243 a15a 2e5c  ..zs.p...."C.Z.\
	0x0020:  8011 00e5 76c6 0000 0101 080a 03d2 1025  ....v..........%
	0x0030:  03d2 140a                                ....

10:14:32.315270 IP dev-db.6033 > dev-app.50544: Flags [F.], seq 173, ack 100, win 227, options [nop,nop,TS val 64099339 ecr 64098341], length 0
	0x0000:  4500 0034 39bd 4000 4006 8a67 c0a8 7a73  E..49.@.@..g..zs
	0x0010:  c0a8 7adb 1791 c570 a15a 2e5c d6d0 2244  ..z....p.Z.\.."D
	0x0020:  8011 00e3 76c6 0000 0101 080a 03d2 140b  ....v...........
	0x0030:  03d2 1025                                ...%

10:14:32.315456 IP dev-app.50544 > dev-db.6033: Flags [.], ack 174, win 229, options [nop,nop,TS val 64098341 ecr 64099339], length 0
	0x0000:  4500 0034 31c9 4000 4006 925b c0a8 7adb  E..41.@.@..[..z.
	0x0010:  c0a8 7a73 c570 1791 d6d0 2244 a15a 2e5d  ..zs.p...."D.Z.]
	0x0020:  8010 00e5 76c6 0000 0101 080a 03d2 1025  ....v..........%
	0x0030:  03d2 140b  

If you need it, we can setup a virtual host and provide you access to this for testing and debugging. Or we can test patches for you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal mysql2 test case and compare its behavior with mysql against ProxySQL on port 6033. Use the supplied tcpdump traces to investigate why mysql2 does not receive the query result; done means the SELECT completes through ProxySQL without hanging.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, node.js
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.