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

Transaction problem with db.query #61

Closed
sdnetwork opened this Issue Mar 16, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@sdnetwork
Contributor

sdnetwork commented Mar 16, 2015

Hi,

i have remarked that on a 2.5.2 super server after a query with node-firebird the oit counter is definitevly locked !

this not happen with node-fierbird version < 0.3.0 (test with 0.1.1 and 0.2.0).

fb.attach(_connection, function (err, cnx) {
    if (err) {
        console.log("can't connect to db");
        return;
    }
    cnx.query("SELECT count(1) FROM TRANSACT", function (err, data) {
        console.log(data);

        cnx.detach(function (err) {
            if (err)
                console.log(err);
        });
    }); 
});

If i run this little exemple on node-firebird >= 0.3.0 i obtain this error on detach :

Error: cannot disconnect database with open transactions (1 active)

so it can explain my OIT (oldest interesting transaction) lock.

i have done a quick comparaison in the node-firebird code to find the change and maybe i have found the problem :

Database.prototype.execute = function(query, params, callback, custom) {
....
in version > 0.3.0 there is a test on isSelect

if (isSelect) {  // i think the problem is here
                if (callback)
                    callback(err, result, meta, isSelect);
                return;
            }

            if (err) {
                transaction.rollback(function() {
                    doError(err, callback);
                });
                return;
            }

            transaction.commit(function(err) {
                if (callback)
                    callback(err, result, meta, isSelect);
            });

so if we do a select query the transaction is neither commit or rollback, and we can't do in the query callback because there is no reference on transaction.

i think we need to remove it or pass in reference the transaction to the callback. But i think guys that do a query with db.quey don't need to manually commit their query.

@sdnetwork

This comment has been minimized.

Contributor

sdnetwork commented Mar 16, 2015

An other thing strange (for my test i have commented the test on isSelect), so i'm sure the commit is done !

i check the OIT before (with gstat -h) =>
OIT => 10
OI => 11
OS => 11
Next transaction => 12
i launch 100 times the little test program and i check the oit afer
OIT => 10
OI => 11
OS=>11
Next transaction => 113

it seems that when we done request with node-firebird the oit is not refresh !

@lafras-h

This comment has been minimized.

lafras-h commented Mar 16, 2015

TI dont know if this is related, but
I observed on windows, the older version ("0.1.4"),
if does not seem to 'really' commit, until you close the connection.
Linux is ok. Not a problem for me yet, windows just runs slower. ;}

On 2015/03/16 07:56 AM, Le Roy Arnaud wrote:

An other thing strange (for my test i have commented the test on
isSelect), so i'm sure the commit is done !

i check the OIT before (with gstat -h) =>
OIT => 10
OI => 11
OS => 11
Next transaction => 12
i launch 100 times the little test program and i check the oit afer
OIT => 10
OI => 11
OS=>11
Next transaction => 113

it seems that when we done request with node-firebird the oit is not
refresh !


Reply to this email directly or view it on GitHub
#61 (comment).

@slachtar

This comment has been minimized.

slachtar commented Mar 16, 2015

Hello,
same problem here under windows with firebird 2.5.3

On Mon, Mar 16, 2015 at 7:29 AM, Lafras notifications@github.com wrote:

TI dont know if this is related, but
I observed on windows, the older version ("0.1.4"),
if does not seem to 'really' commit, until you close the connection.
Linux is ok. Not a problem for me yet, windows just runs slower. ;}

On 2015/03/16 07:56 AM, Le Roy Arnaud wrote:

An other thing strange (for my test i have commented the test on
isSelect), so i'm sure the commit is done !

i check the OIT before (with gstat -h) =>
OIT => 10
OI => 11
OS => 11
Next transaction => 12
i launch 100 times the little test program and i check the oit afer
OIT => 10
OI => 11
OS=>11
Next transaction => 113

it seems that when we done request with node-firebird the oit is not
refresh !


Reply to this email directly or view it on GitHub
<
#61 (comment)
.


Reply to this email directly or view it on GitHub
#61 (comment)
.

Slah Lachtar
Tel. (+216) 98 221 575

@sdnetwork

This comment has been minimized.

Contributor

sdnetwork commented Mar 16, 2015

The commit that change the behaviour :

updated: pooling and better data selection

Maybe petersirka can help us ?

@sdnetwork

This comment has been minimized.

Contributor

sdnetwork commented Mar 16, 2015

For the behaviour on OIT, OAT, OST it happens only if we do one transaction on one connection.

  1. open connection
  2. open transascation
  3. do query
  4. commit transaction
  5. close connection

i ask firebird support to know if this behaviour is normal !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment