sidorares / sidorares/node-mysql2

Error while stress testing

Open
#471 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation
Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

Hi,

I am using lastest version of mysql2 with following sequelize configuration

Node: v.4.4.1
mysql: v5.6.21
sequelize: v2.0.0-dev9
sequelize: configuration

var defaultOptions = {
        "host": default_config.host,
        "port": default_config.port,
        "dialectModulePath": 'mysql2',
        "dialect": "mysql",
        "define": {
            "timestamps": false,
            "freezeTableName": true,
            "syncOnAssociation": false
        },
        "pool": {
            "maxConnections": 10,
            "minConnections": 10,
            "maxIdleTime": 10000,
            "handleDisconnects": true
        },
        "logging": (default_config.logging == undefined ? function(x) { defaultLogger.trace(x); } : default_config.logging),
		"dialectOptions": { multipleStatements: true }
    };

after adding some stress + run test cases i am getting following error

Error message: write after end
Stack trace: Error: write after end
    at writeAfterEnd (_stream_writable.js:166:12)
    at Socket.Writable.write (_stream_writable.js:211:5)
    at Socket.write (net.js:642:40)
    at Connection.write (/project/node_modules/mysql2/lib/connection.js:224:15)
    at Connection.writePacket (/project/node_modules/mysql2/lib/connection.js:265:10)
    at Quit.start (/project/node_modules/mysql2/lib/commands/quit.js:21:14)
    at Quit.Command.execute (/project/node_modules/mysql2/lib/commands/command.js:39:20)
    at Connection.handlePacket (/project/node_modules/mysql2/lib/connection.js:417:28)
    at Connection.addCommand (/project/node_modules/mysql2/lib/connection.js:440:10)
    at Connection.end (/project/node_modules/mysql2/lib/connection.js:804:22)
    at module.exports.disconnect (/project/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:265:12)
    at Object.pool.Pooling.Pool.destroy (/project/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:137:22)
    at Object.me.destroy (/project/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:149:13)
    at removeIdle (/project/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:178:10)
    at Timer.listOnTimeout (timers.js:92:15)
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
    at ServerResponse.res.setHeader (/project/node_modules/connect/lib/patch.js:134:22)
    at ServerResponse.header (/project/node_modules/express/lib/response.js:719:10)
    at ServerResponse.send (/project/node_modules/express/lib/response.js:164:12)
    at done (/project/node_modules/express/lib/response.js:956:10)
    at View.exports.renderFile [as engine] (/project/node_modules/ejs/lib/ejs.js:318:3)
    at View.render (/project/node_modules/express/lib/view.js:126:8)
    at tryRender (/project/node_modules/express/lib/application.js:639:10)
    at EventEmitter.render (/project/node_modules/express/lib/application.js:591:3)
    at ServerResponse.render (/project/node_modules/express/lib/response.js:960:7)
    at /project/node_modules/express-partials/index.js:82:15
    at View.exports.renderFile [as engine] (/project/node_modules/ejs/lib/ejs.js:318:3)
    at View.render (/project/node_modules/express/lib/view.js:126:8)
    at tryRender (/project/node_modules/express/lib/application.js:639:10)
    at EventEmitter.render (/project/node_modules/express/lib/application.js:591:3)
    at ServerResponse.render (/project/node_modules/express/lib/response.js:960:7)
    at ServerResponse.res.render (/project/node_modules/express-partials/index.js:55:9)
    at Domain.<anonymous> (/project/config/express.js:53:23)
    at emitOne (events.js:77:13)
    at Domain.emit (events.js:169:7)
    at emitError (domain.js:66:24)
    at Domain.errorHandler [as _errorHandler] (domain.js:126:16)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining mysql2/lib/connection.js, mysql2/lib/commands/quit.js, and sequelize/lib/dialects/mysql/connector-manager.js at the stack-trace paths. Reproduce the failure with the stated Node, MySQL, Sequelize, mysql2, and pool configuration under stress, then determine whether the connection is being written to after shutdown and whether the resulting request sends more than one response.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, node.js
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.