Skip to content

SELECT Never Returns... #126

Closed
Closed

Description

@bfoust

findAll() never calls "success()"

I see the logger print out:

SELECT * FROM task

But neither success(), nor failure() is ever called.

(3) findAll

Task.findAll().success(function(tasks) {
        // never gets here...
    }).failure(function (err) {
        // or here...
        res.send('Error: ' + err);
    });

---- Setup ---

(1) Open the DB

var Sequelize = require('sequelize');   // mysql by default
var sequelize = new Sequelize('myDbName', 'root', 'mypassword', {
    host: "127.0.0.0",
    port: 3306
});

(2) Define the model

var Task = sequelize.define('task', {
        task_id: Sequelize.INTEGER,
        task_name: Sequelize.TEXT,
    },
    {
        underscored: true,
        freezeTableName: true
    }
);

Activity

  1. sdepold commented on Feb 1, 2012

    @sdepold
    Member

    and is .on('success') working?

    Am 01.02.2012 um 17:31 schrieb [email protected]:

    findAll() never calls "success()"

    I see the logger print out:

    SELECT * FROM task

    But it neither success(), nor failure() is ever called.

    (3) Task.findAll().success(function(tasks) {
    // never gets here...
    }).failure(function (err) {
    // or here...
    res.send('Error: ' + err);
    });

    ---- Setup ---

    (1) Open the DB

    var Sequelize = require('sequelize'); // mysql by default
    var sequelize = new Sequelize('myDbName', 'root', 'mypassword', {
    host: "127.0.0.0",
    port: 3306
    });

    (2) Define the model

    var Task = sequelize.define('task', {
    task_id: Sequelize.INTEGER,
    task_name: Sequelize.TEXT,
    },
    {
    underscored: true,
    freezeTableName: true
    }
    );


    Reply to this email directly or view it on GitHub:
    https://github.com/sdepold/sequelize/issues/126

  2. bfoust commented on Feb 1, 2012

    @bfoust
    Author

    @sdepold No, I should have mentioned that -- the .on('success') and on('failure') methods do not get called, either. That's why I switched to just success(function(data){}) and failure(err).

    Any ideas of how to track this down?

    Connecting with the 'mysql' module works fine and it returns data using the same query immediately.

  3. sdepold commented on Feb 1, 2012

    @sdepold
    Member

    will check it in an hour.

    Am Mittwoch, 1. Februar 2012 um 19:51 schrieb bfoust:

    @sdepold No, I should have mentioned that -- the .on('success') and on('failure') methods do not get called, either. That's why I switched to just success(function(data){}) and failure(err).

    Any ideas of how to track this down?

    Connecting with the 'mysql' module works fine and it returns data using the same query immediately.


    Reply to this email directly or view it on GitHub:
    https://github.com/sdepold/sequelize/issues/126#issuecomment-3764622

  4. sdepold commented on Feb 1, 2012

    @sdepold
    Member

    ok i just checked locally. can you please try this as well:

    var Sequelize = require("sequelize")
    undefined
    var sequelize = new Sequelize('performance_analysis_sequelize', 'root')
    undefined
    var Entry = sequelize.define('Entry', {
    ... number: Sequelize.INTEGER,
    ... string: Sequelize.STRING
    ... })
    undefined

    undefined
    Entry.findAll().success(function(entries){ console.log(entries)})
    { fct: [Function],
    _events: { success: [Function] } }
    Executing: SELECT * FROM Entries;
    []
    Entry.findAll().success(function(entries){ console.log(entries)})
    { fct: [Function],
    _events: { success: [Function] } }
    Executing: SELECT * FROM Entries;
    [ { attributes: [ 'number', 'string', 'id', 'createdAt', 'updatedAt' ],
    validators: {},
    __factory:
    { options: [Object],
    name: 'Entry',
    tableName: 'Entries',
    rawAttributes: [Object],
    modelFactoryManager: [Object],
    associations: {},
    validate: {},
    autoIncrementField: 'id' },
    __options:
    { underscored: false,
    hasPrimaryKeys: false,
    timestamps: true,
    paranoid: false,
    instanceMethods: {},
    classMethods: {},
    validate: {},
    freezeTableName: false,
    number: 'INTEGER',
    string: 'VARCHAR(255)',
    id: 'INTEGER NOT NULL auto_increment PRIMARY KEY',
    createdAt: 'DATETIME NOT NULL',
    updatedAt: 'DATETIME NOT NULL' },
    number: 1,
    string: 's',
    id: 1,
    createdAt: Invalid Date,
    updatedAt: Invalid Date,
    isNewRecord: false } ]

    i already had this database/table so i didn't call sync but added an entry to the table via sequel pro

  5. sdepold commented on Feb 1, 2012

    @sdepold
    Member

    which version are u using btw? the log is very strange: SELECT * FROM task it should be SELECT * FROM task``

  6. sdepold commented on Feb 1, 2012

    @sdepold
    Member

    and i tried your example:

    var Task = sequelize.define('task', {
    ... task_id: Sequelize.INTEGER,
    ... task_name: Sequelize.TEXT,
    ... },
    ... {
    ..... underscored: true,
    ..... freezeTableName: true
    ..... }
    ... );
    undefined
    Task.sync()
    { fct: [Function] }
    Executing: CREATE TABLE IF NOT EXISTS task (task_id INTEGER, task_name TEXT, id INTEGER NOT NULL auto_increment , created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;
    Task.findAll().success(function(tasks){ console.log('asd') })
    { fct: [Function],
    _events: { success: [Function] } }
    Executing: SELECT * FROM task;
    asd
    Task.findAll().success(function(tasks){ console.log(tasks) })
    { fct: [Function],
    _events: { success: [Function] } }
    Executing: SELECT * FROM task;
    [ { attributes: [ 'task_id', 'task_name', 'id', 'created_at', 'updated_at' ],
    validators: {},
    __factory:
    { options: [Object],
    name: 'task',
    tableName: 'task',
    rawAttributes: [Object],
    modelFactoryManager: [Object],
    associations: {},
    validate: {},
    autoIncrementField: 'id' },
    __options:
    { underscored: true,
    hasPrimaryKeys: false,
    timestamps: true,
    paranoid: false,
    instanceMethods: {},
    classMethods: {},
    validate: {},
    freezeTableName: true,
    task_id: 'INTEGER',
    task_name: 'TEXT',
    id: 'INTEGER NOT NULL auto_increment PRIMARY KEY',
    created_at: 'DATETIME NOT NULL',
    updated_at: 'DATETIME NOT NULL' },
    task_id: 123,
    task_name: 'foo',
    id: 1,
    created_at: Invalid Date,
    updated_at: Invalid Date,
    isNewRecord: false } ]

  7. bfoust commented on Feb 1, 2012

    @bfoust
    Author

    Yes, The backticks are difficult to get to show up. Here it is more accurately:

    Executing: SELECT * FROM task;

    I'm using version 1.3.3:

    ├─┬ [email protected]
    │ ├── [email protected]
    │ ├── [email protected]
    │ ├── [email protected]
    │ ├─┬ [email protected]
    │ │ └─┬ [email protected]
    │ │ └── [email protected]
    │ ├── [email protected]
    │ ├── [email protected]
    │ └── [email protected]

    And the task table already exists (and has many more fields than I use in my test code above). Is there a way to turn on verbose mode to see where sequelize is hanging?

  8. sdepold commented on Feb 1, 2012

    @sdepold
    Member

    hmm no not really. can you check another, new model, create some entries and read them? can u also check the find method? are you sure that u didnt missspelled smth?

    Am 01.02.2012 um 21:10 schrieb [email protected]:

    Yes, I typed the logging output incorrectly. Here it is copy/pasted:

    Executing: SELECT * FROM task;

    I'm using version 1.3.3:

    ├─┬ [email protected]
    │ ├── [email protected]
    │ ├── [email protected]
    │ ├── [email protected]
    │ ├─┬ [email protected]
    │ │ └─┬ [email protected]
    │ │ └── [email protected]
    │ ├── [email protected]
    │ ├── [email protected]
    │ └── [email protected]

    And the task table already exists (and has many more fields than I use in my test code above). Is there a way to turn on verbose mode to see where sequelize is hanging?


    Reply to this email directly or view it on GitHub:
    https://github.com/sdepold/sequelize/issues/126#issuecomment-3766144

  9. bfoust commented on Feb 1, 2012

    @bfoust
    Author

    OK, I'll try find() and report back.

    What is smth?

    On Wed, Feb 1, 2012 at 1:13 PM, Sascha Depold <
    [email protected]

    wrote:

    can u also check the find method? are you sure that u didnt missspelled
    smth?

  10. bfoust commented on Feb 2, 2012

    @bfoust
    Author

    Interesting. I'm not sure if it's switching to use find(), calling sync() which I wasn't doing before, or just using a new table, but now failure() gets called after a long delay:

    var Test = sequelize.define('test', {
        test_id: Sequelize.INTEGER,
        test_name: Sequelize.TEXT,
    },
    {
        underscored: true,
        freezeTableName: true
    }
    );
    
    Test.sync();
    Test.create({test_id:1, test_name:'Entry 1'});
    Test.find({where:{test_id: 1}}).success(function(tasks) {
        console.log("=====> Test Find succeeded");
    }).failure(function (err) {
            console.log("=====> Test Find failed.");
        });
    

    Executing: INSERT INTO test (test_id,test_name,id,created_at,updated_at) VALUES (1,'Entry 1',NULL,'2012-02-01 17:21:54','2012-02-01 17:21:54');
    Executing: SELECT * FROM test WHERE test_id=1 LIMIT 1;
    Executing: CREATE TABLE IF NOT EXISTS test (test_id INTEGER, test_name TEXT, id INTEGER NOT NULL auto_increment , created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;
    ^[=====> Test Find failed.

    This last line appears after more than 2-3 minutes elapse. Why would it be hanging the SELECT until timing out?

    The same code calling findAll() gives similar output, but I didn't wait long enough to see if the timeout leads to failure() being called:

    Executing: INSERT INTO test (test_id,test_name,id,created_at,updated_at) VALUES (1,'Entry 1',NULL,'2012-02-01 17:16:47','2012-02-01 17:16:47');
    Executing: SELECT * FROM test;
    Executing: CREATE TABLE IF NOT EXISTS test (test_id INTEGER, test_name TEXT, id INTEGER NOT NULL auto_increment , created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;

    Note: the 'test' table is never created, although:
    a) there is no 'test' table, and
    b) the CREATE TABLE IF NOT EXISTS is being executed

  11. sdepold commented on Feb 2, 2012

    @sdepold
    Member

    something :) it would also help to get the schema of that specific table.

    Am 01.02.2012 um 23:24 schrieb [email protected]:

    OK, I'll try find() and report back.

    What is smth?

    On Wed, Feb 1, 2012 at 1:13 PM, Sascha Depold <
    [email protected]

    wrote:

    can u also check the find method? are you sure that u didnt missspelled
    smth?


    Reply to this email directly or view it on GitHub:
    https://github.com/sdepold/sequelize/issues/126#issuecomment-3768485

  12. sdepold commented on Feb 2, 2012

    @sdepold
    Member

    ah! please do Task.sync().success and go on inside the success callback. you r trying to create table entries into a table which isnt existing. check the log -> insert before create table

    Am 02.02.2012 um 02:30 schrieb [email protected]:

    Interesting. I'm not sure if it's switching to use find(), calling sync() which I wasn't doing before, or just using a new table, but now failure() gets called after a long delay:

    var Test = sequelize.define('test', {
    test_id: Sequelize.INTEGER,
    test_name: Sequelize.TEXT,
    },
    {
    underscored: true,
    freezeTableName: true
    }
    );

    Test.sync();
    Test.create({test_id:1, test_name:'Entry 1'});
    Test.find({where:{test_id: 1}}).success(function(tasks) {
    console.log("=====> Test Find succeeded");
    }).failure(function (err) {
    console.log("=====> Test Find failed.");
    });

    Executing: INSERT INTO test (test_id,test_name,id,created_at,updated_at) VALUES (1,'Entry 1',NULL,'2012-02-01 17:21:54','2012-02-01 17:21:54');
    Executing: SELECT * FROM test WHERE test_id=1 LIMIT 1;
    Executing: CREATE TABLE IF NOT EXISTS test (test_id INTEGER, test_name TEXT, id INTEGER NOT NULL auto_increment , created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;
    ^[=====> Test Find failed.

    This last line appears after more than 2-3 minutes elapse. Why would it be hanging the SELECT until timing out?

    The same code calling findAll() gives similar output, but I didn't wait long enough to see if the timeout leads to failure() being called:

    Executing: INSERT INTO test (test_id,test_name,id,created_at,updated_at) VALUES (1,'Entry 1',NULL,'2012-02-01 17:16:47','2012-02-01 17:16:47');
    Executing: SELECT * FROM test;
    Executing: CREATE TABLE IF NOT EXISTS test (test_id INTEGER, test_name TEXT, id INTEGER NOT NULL auto_increment , created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;


    Reply to this email directly or view it on GitHub:
    https://github.com/sdepold/sequelize/issues/126#issuecomment-3771012

  13. sdepold commented on Feb 2, 2012

    @sdepold
    Member

    hmm you never seem to use .success when syncing, creating or finding objects. btw whoch version of mysql r u using?

    Am 02.02.2012 um 02:30 schrieb [email protected]:

    Interesting. I'm not sure if it's switching to use find(), calling sync() which I wasn't doing before, or just using a new table, but now failure() gets called after a long delay:

    var Test = sequelize.define('test', {
    test_id: Sequelize.INTEGER,
    test_name: Sequelize.TEXT,
    },
    {
    underscored: true,
    freezeTableName: true
    }
    );

    Test.sync();
    Test.create({test_id:1, test_name:'Entry 1'});
    Test.find({where:{test_id: 1}}).success(function(tasks) {
    console.log("=====> Test Find succeeded");
    }).failure(function (err) {
    console.log("=====> Test Find failed.");
    });

    Executing: INSERT INTO test (test_id,test_name,id,created_at,updated_at) VALUES (1,'Entry 1',NULL,'2012-02-01 17:21:54','2012-02-01 17:21:54');
    Executing: SELECT * FROM test WHERE test_id=1 LIMIT 1;
    Executing: CREATE TABLE IF NOT EXISTS test (test_id INTEGER, test_name TEXT, id INTEGER NOT NULL auto_increment , created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;
    ^[=====> Test Find failed.

    This last line appears after more than 2-3 minutes elapse. Why would it be hanging the SELECT until timing out?

    The same code calling findAll() gives similar output, but I didn't wait long enough to see if the timeout leads to failure() being called:

    Executing: INSERT INTO test (test_id,test_name,id,created_at,updated_at) VALUES (1,'Entry 1',NULL,'2012-02-01 17:16:47','2012-02-01 17:16:47');
    Executing: SELECT * FROM test;
    Executing: CREATE TABLE IF NOT EXISTS test (test_id INTEGER, test_name TEXT, id INTEGER NOT NULL auto_increment , created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB;


    Reply to this email directly or view it on GitHub:
    https://github.com/sdepold/sequelize/issues/126#issuecomment-3771012

  14. andyburke commented on Apr 24, 2012

    @andyburke
    Contributor

    So I am seeing something akin to this, but only after some amount of time where things have been working fine.

    That is, eventually my selects (and, it seems, all other db calls) will never call back either their success or failure methods. I'm suspicious it has something to do with the database connection being gone for some reason, but sequelize believing it's still there. My database has an interactive/wait_timeout of 8 hours, so it seems unlikely that it's the db closing the connection (as I believe I've seen this happen less than 8 hours after launching my node process).

    I am tempted to try pulling the latest connection pooling code in the hopes that if there is a bug in the current connections code I could avoid it.

    I wish I had a better reproduction case. One thing that might be helpful would be to emit events on connect/disconnect from mysql. At least then I could try to have some logging to get a better grip on what's happening. (Of course, if my theory is right, the mysql connection would be going away but sequelize would not realize and would not emit a disconnect.)

  15. andyburke commented on Apr 25, 2012

    @andyburke
    Contributor

    Some more info: when I get into this state, where my db calls are just hanging. If I either a) restart node or b) restart mysql suddenly new calls work.

  16. andyburke commented on Apr 25, 2012

    @andyburke
    Contributor

    Should this:

      ConnectorManager.prototype.__defineGetter__('hasNoConnections', function() {
        return (this.queue.length == 0) && (this.activeQueue.length == 0) && this.client._queue && (this.client._queue.length == 0)
      })

    Instead be this:

      ConnectorManager.prototype.__defineGetter__('hasNoConnections', function() {
        return (this.queue.length == 0) && (this.activeQueue.length == 0) && !( this.client._queue && (this.client._queue.length > 0) )
      })

    The way I read the original is that if there is no this.client._queue it will return false, indicating that there are connections. That seems incorrect to me. My revision attempts to say: if there is a client queue and it has items, then we still have connections.

    But frankly, I get confused by inverted booleans, maybe it would be better to do:

      ConnectorManager.prototype.__defineGetter__('hasConnections', function() {
        return (this.queue.length > 0) || (this.activeQueue.length > 0) || ( this.client._queue && (this.client._queue.length > 0) )
      })

    Thoughts?

  17. durango commented on Jun 19, 2013

    @durango
    Member

    I'm assuming this is fixed, as it's a very old version of SequelizeJS as well, and I've never seen this problem occur. @andyburke if you ever experience this problem with 1.6 or 1.7 please let me know, but for now I'm closing the ticket/cleaning up the issues page :)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions