Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Andrey Sidorov
    @sidorares
    can you check which version of mysql2 you have?
    if it's v1.0-rc I suggest to downgrade to last stable. The issue is definitely going to be fixed before 1.0 release
    Cas du Plessis
    @go4cas
    1.0.0-rc.1
    okay, will downgrade, and let u know
    thanks, @sidorares
    Cas du Plessis
    @go4cas
    @sidorares , downgrading to 0.15.8 did not make a diiference
    Cas du Plessis
    @go4cas
    @sidorares, i've got a bit more detail about my issue. i have narrowed it down to the scenario where node or mysql closes the connection. this happens after 60 minutes of being idle. i can safely assume it is the node-mysql connection, as all the other elements (nginx, node connection to mongo, other 3rd party api from node, etc) still function 100% after the 60 minutes
    i can also confirm that this happens for both mysql and mysql2 packages
    i have put in logging all other the code, to try and trap whatever event is causing this, but with no luck
    so, the way i'm getting past this for now is, by including the following in my wrapper lib:
    setInterval(() => {
      pool.query('SELECT 1');
    }, 600000);
    you have any other ideas? (i'm not too keen to keep my solution as a long-term fix)
    Cas du Plessis
    @go4cas
    here's my complete revised wrapper lib, in case you have some suggestions:
    'use strict';
    
    const Chalk = require('chalk');
    const mysql = require('mysql2');
    const logger = require('winston');
    
    const pool = mysql.createPool({
      host: process.env.MYSQL_HOST,
      port: process.env.MYSQL_PORT,
      user: process.env.MYSQL_USER,
      password: process.env.MYSQL_PASSWORD,
      database: process.env.MYSQL_DATABASE,
      connectionLimit: process.env.MYSQL_POOL_CONNECTION_LIMIT
    });
    
    let getConnection = (callback) => {
      pool.getConnection((err, connection) => {
        if (err) {
          if (connection) {
            logger.log('warn','DB - MySQL attempting to release pool connection');
            connection.release();
          } else {
            logger.log('error','DB - MySQL error connecting to pool');
          }
          callback(err);
        };
    
        callback(err, connection);
        connection.release();
      });
    };
    
    pool.on('connection', (connection) => {
      logger.log('info','DB - MySQL pool connection opened');
    });
    
    pool.on('enqueue', () => {
      logger.log('info','DB - MySQL waiting for available pool connection');
    });
    
    setInterval(() => {
      pool.query('SELECT 1');
    }, 600000);
    
    module.exports = getConnection;
    scippio
    @scippio
    Hi all... I have a problem with transactions... I tried: conn.query('START TRANSACTIONS').then ... conn.query('my query').then.... conn.query('COMMIT')
    But every conn.query('my query') throw:
    [ ResultSetHeader {
        fieldCount: 0,
        affectedRows: 1,
        insertId: 0,
        serverStatus: 3,
        warningStatus: 0,
        changedRows: 1 },
      undefined ]
    It's only simple update :-(
    scippio
    @scippio
    Hmm I maybe have solution ... I changed conn.query('my query').then only to: conn.query('my query') and it's ok now :)
    scippio
    @scippio
    Hi all again :)
    I have a problem with pool closing in my Restify request ...
    Sometimes I get this error: Error: Pool is closed.
    I created pool by Mysql.createPoolPromise() with connectionLimit: 5 ...
    I have server.get('path' (req, res, next) => { }) and inside I creating the pool then call getConnection() then conn.query() and conn.release ... after all of this I call end() on the pool.... all is ok, but sometimes I get the Pool is closed. error... I don't know why because every request create pool...
    scippio
    @scippio
    :-/
    Gregory Magarshak
    @EGreg
    how is node-mysql2 different than node-mysql?
    or felixge/mysql
    Andrey Sidorov
    @sidorares
    hey @EGreg . It's completely separate implementation internally.
    from user point of view - usually faster (sometimes 3x times faster) and has support for some extra features ( prepared statements, compression etc )
    Are you considering which one to use? They are mostly compatible at api level so as long as you use common subset of features it's easy to switch back and forth
    Gregory Magarshak
    @EGreg
    yeah I use a common subset of features of felixge/mysql
    wait no, I use node-mysql
    actually use "mysql" : "2.9.x"
    what's that on
    Andrey Sidorov
    @sidorares
    felixge/node-mysql is moved to mysqljs org
    but still same "mysql" npm name
    Gregory Magarshak
    @EGreg
    I see, okay.
    Akshat
    @akshatbhargava123
    Hello is this room still active?
    What is the preferable choice to use for mysql database now?
    Please help, thanks
    Andrey Sidorov
    @sidorares
    Hi! More or less active, at least I get notifications
    "What is the preferable choice to use for mysql database now?" - depends, for small to mid size projects I prefer not to use ORMs and just fire queries using driver directly
    from user point of view there is almost no difference between mysql and mysql2
    Roel
    @roelzkie15
    does anyone here came across this issue?
    Roel
    @roelzkie15
    oh never mind
    Ronald T. Casili
    @nvlled
    Is it optional to end a connection? I see examples that do not call .end().
    Andrey Sidorov
    @sidorares
    The client does not end it for you
    So if you want to close connection you need to call .end()
    Ronald T. Casili
    @nvlled
    okay thanks
    Santiago Suárez
    @santiagosuarezecheverri
    hi
    I have a problem with mysql in nodejs
    no connect to database but the database exist
    Jacob Bogers
    @Jacob_Bogers_twitter
    Hi bros