Error: Cannot enqueue Query after fatal error in mysql node

前端 未结 3 1038
离开以前
离开以前 2021-01-15 16:45

I am using felixge/node-mysql. Also I am using express-myconnection which prevents mysql timeout and in turn prevents killing of node server. What I am doing is logging the

相关标签:
3条回答
  • 2021-01-15 16:56

    I had the same issue. Came across one solution -

    Re-Install MySQl and while doing so, in the configuration step, select "legacy encryption" option instead and finish the installation.

    Hope this helps!

    0 讨论(0)
  • 2021-01-15 16:57

    Actually, I decided to google your error for you, and after reading this thread: https://github.com/felixge/node-mysql/issues/832 I realized that you're not releasing the connection after the first query completes, and so the pool never tries to issue you a new one. You were correct that the stale connection might be the problem. here's how you fix that if it is:

    upload.on('begin', function (fileInfo, reqs, resp) { 
        var fileType = resp.req.fields.file_type;
        var originalFileName = fileInfo.name;
         var renamedFilename = file.fileRename(fileInfo,fileType);
        /*renaming the file */
        fileInfo.name = renamedFilename;
    
        /*start: log the details in database;*/
        var utcMoment = conf.moment.utc();
        var UtcSCPDateTime = new Date( utcMoment.format() );
        var activityData = {
            activity_type     : conf.LIST_UPLOAD_BEGIN,
            username          : test ,
            message           : 'test has started the upload process for the file',
            activity_datetime : UtcSCPDateTime 
        };
        reqs.params.activityData = activityData;
        req.getConnection(function(err,connection) {
        var dbData = req.params.activityData;
        var activity_type = dbData.activity_type;
        console.dir("[ Connection ID:- ] "+connection.threadId+' ] [ Activity type:- ] '+activity_type);
        var insertQuery = connection.query("INSERT INTO tblListmanagerActivityLog SET ? ",dbData, function(err, result) {
            if (err) {
                console.log("Error inserting while performing insert for activity "+activity_type+" : %s ",err );
            } else {
                console.log('Insert successfull');
            }
            /// Here is the change:
            connection.release();
        });
    
    });
        /*end: log the details in database;*/
    });
    
    0 讨论(0)
  • 2021-01-15 17:08

    For pool connection to work we need to comment out https://github.com/pwalczyszyn/express-myconnection/blob/master/lib/express-myconnection.js#L84 this line. Hope it helps anyone facing the same issue.

    Also we can use single connection option.

    0 讨论(0)
提交回复
热议问题