I have a webserver running a Node.js v1.0.10 that connects to a SA16. So, every page that needs data from the DB, opens a new connection and closes it at the end. If I call more than one page at same time, I'll have more than one connection to the database. The problem starts when I have multiple pages running at the same time and the first one calls the "connection.disconnect" method. At this time, all other connections are affected and all other pages get an connection error. It seems the connection.disconnect closes all opened connections. I´m creating a new connection in every single page like the GitHub example:
What am I doing wrong? Thanks for your time! asked 27 Jun '16, 09:47 Thiago Reis |
Version 1.0.11 (just published to npm) should fix this issue. answered 30 Jun '16, 08:45 Graeme Perrow Thank you very much. Very fast. Really appreciate that.
(30 Jun '16, 09:13)
Thiago Reis
|
After checking with others who know this module much better than I, it appears the behavior you are seeing doesn't make much sense. And we have not heard of any other reports ... so ...
You might need to add some addional error logging/catpuring to see what is actually happening here. The speicifics of your connection string might reveal something. Adding LogFile= ... to that connection string would help capture what is happening at the native connectivity level.
If you capture more information but can't make much more sense of that do consider contacting product support so this can be investigated.
Hm, looks strange. Is it really necessary to connect/disconnect to the database every time? I think this is expensive, and I'd better invent (or borrow) the generic pool. E.g. https://github.com/coopernurse/node-pool
Talking to the developer it seems that the Node is crashing itself by a memory violation as he calls the disconnect method, just when there is another page still connected to the database.
I'll try to get the logs as Nick suggested. Thanks.
We´ve tried to open a single connection, but there is some queries that take about 2 minutes to run and all other queries got stuck in a queue waiting for this long one to finish.
The second try was to open the connections and not close them. But we have 10 thousand users and 5 requests per second. I got a huge number of opened connections in my database. I really don't like that.
I got the logs. There is a memory violation at Node server everytime I try to disconnect a single connection, having another connection still running.
If I have only one connection, it´s all right.
If I have more than one simultaneously connection to the database, the first DISCONNECT try will generate a memory violation at Node server.
It´s not related with the disconnection itself, as if I disconnect it through the database (drop connection statement), there is no such error at Node server.
Should I open a incident?!
It seems there could be a fix in the works for a related report ... stay tuned. {see this thread on GitHub https://github.com/sqlanywhere/node-sqlanywhere/issues/15 }
Nick, thank you. This issue was issued by our development team. This is really a bug. Thanks for your time.