0

I am running a Node JS + Socket.io server which makes a database connection with MySQL Server.

I have written the following code at the global level( i.e. not inside any of the functions )

// All this code is at Global level...    
var mysql       = require( 'mysql' );
var GDbConnection = mysql.createConnection( {
    host            : DB_DATA_HOST,
    user            : DB_DATA_USER,
    password        : DB_DATA_PASS,
    database        : DB_DATA_NAME,
    insecureAuth    : true
});

The connection gets established and I am able to run all kinds of queries.

But the problem is that when I try to find the number of connections made with MySQL Server by running SHOW PROCESSLIST; command externally, it does not display that database connection.

As far as I know in such a case a persistent database connection is made. Can anybody explain this behavior of NodeJS and MySQL.

Also I inserted a query that takes ~5 mins to execute, while the query was getting executed, I was able to see the database connection using SHOW PROCESSLIST;

Any help on understanding this behavior would be appreciated.

Manu
  • 901
  • 1
  • 8
  • 28
  • What client are you using to run `SHOW PROCESSLIST`? Are you using some fancy GUI that would "helpfully" hide cruft from you? – 000 Jul 22 '13 at 19:32
  • I checked by logging in through the linux shell. :D – Manu Jul 23 '13 at 05:49
  • I can't say if this is a Node JS issue, or a MySQL issue. I am getting a feeling that the connection is not a persistent one. Could it be that it gets created just before the query is getting executed, and gets destroyed after the query has finished executing. Can you check if that happens with you as well, please? – Manu Jul 23 '13 at 06:00
  • You can check this by tailing your mysql General Query Log. – 000 Jul 23 '13 at 13:31
  • As I said, query is getting executed. While the query was running, I could see the connection and query using the `SHOW PROCESSLIST` only. It seems that the connection is not persistent. I think it gets created just before the query is gets executed. – Manu Jul 24 '13 at 07:00
  • So check your General Query Log to see when connections are created and dropped. The General Query Log does have that information. – 000 Jul 24 '13 at 14:51
  • Oh.. probably I need to get more information about "General Query Log".. I will get back to you regarding this.. Thanks.. :) – Manu Jul 24 '13 at 17:07

0 Answers0