Skip to content

Connection pool doesnt reconnect with MySQL after server dies and comes back (only with replication configured) #9541

Closed

Description

@stringbeans

What are you doing?

my repro steps using mariadb 10.2 and sequelize v4.37.10:

  1. start my api server
  2. issue a query (works fine)
  3. stop the database
  4. issue a query (fails due to db being down)
  5. start the database
  6. issue a query (continues to fail)

My config looks like so...

{
    dialect: 'mysql',
    dialectOptions: {
      multipleStatements: true,
      decimalNumbers: true
    },
    // replication seems to break it
    replication: {
      write: {
        host: process.env.MYSQL_MASTER_HOST,
        port: process.env.MYSQL_MASTER_PORT,
        username: process.env.MYSQL_MASTER_USERNAME,
        password: process.env.MYSQL_MASTER_PASSWORD
      },
      read: [{
        host: process.env.MYSQL_SLAVE_HOST,
        port: process.env.MYSQL_SLAVE_PORT,
        username: process.env.MYSQL_SLAVE_USERNAME,
        password: process.env.MYSQL_SLAVE_PASSWORD
      }]
    },
    pool: {
      max: 3,
      min: 0,
      idle: 10000,
      evict: 10000,
      acquire: 10000
    },
    define: {
      timestamps: false
    }
}

What do you expect to happen?

After the database is restarted, I should not have to restart the api server to issue queries. I would expect the connection pool to self-heal and begin issuing queries again.

What is actually happening?

All subsequent queries after the database comes back up will time out.

Note: This seems to happen ONLY if I have replication configured. If I turn replication off the self-recovery works. Also note that on my local environment, the MASTER and SLAVE configs are the same

Dialect: mysql
Dialect version: [email protected]
Database version: mariadb 10.2.13
Sequelize version: 4.37.10
Tested with latest release: Yes (4.37.10)

Activity

  1. stringbeans commented on Jun 16, 2018

    @stringbeans
    Author

    On closer inspection, it looks as though the pool reconnection WORKS if I don't specify the replication object in my configuration and instead just use a single connection. Also, maybe an important detail is that locally my master and my slave are both pointing to the same database.

  2. knoxcard commented on Jun 17, 2018

    @knoxcard
    Contributor

    Close ticket?

  3. stringbeans commented on Jun 17, 2018

    @stringbeans
    Author

    @knoxcard no its still an issue except it only seems to affect configurations with replication... i'll update the original post to include these details

  4. changed the title [-]Connection pool doesnt reconnect with MySQL after server dies and comes back[/-] [+]Connection pool doesnt reconnect with MySQL after server dies and comes back (only with replication configured)[/+] on Jun 18, 2018
  5. added
    type: bug
    on Jun 24, 2018
  6. gsogol commented on Aug 31, 2018

    @gsogol

    I get the same

  7. sushantdhiman commented on Oct 28, 2018

    @sushantdhiman
    Contributor

    Fixed by #10051

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

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions