Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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:

var sqlanywhere = require('sqlanywhere');
var conn = sqlanywhere.createConnection();
var conn_params = {....};

conn.connect ...
conn.exec ...
conn.disconnect();

What am I doing wrong?

Thanks for your time!

asked 27 Jun '16, 09:47

Thiago%20Reis's gravatar image

Thiago Reis
32681120
accept rate: 40%

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.

(28 Jun '16, 10:15) Nick Elson S...

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

(28 Jun '16, 13:33) Vlad

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.

(28 Jun '16, 16:30) Thiago Reis

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?!

(29 Jun '16, 07:47) Thiago Reis

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 }

(29 Jun '16, 14:45) Nick Elson S...

Nick, thank you. This issue was issued by our development team. This is really a bug. Thanks for your time.

(29 Jun '16, 14:58) Thiago Reis
More comments hidden
showing 5 of 6 show all flat view

Version 1.0.11 (just published to npm) should fix this issue.

permanent link

answered 30 Jun '16, 08:45

Graeme%20Perrow's gravatar image

Graeme Perrow
9.6k379124
accept rate: 54%

Thank you very much. Very fast. Really appreciate that.

(30 Jun '16, 09:13) Thiago Reis
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×23
×21

question asked: 27 Jun '16, 09:47

question was seen: 1,762 times

last updated: 30 Jun '16, 09:13