0
votes

I have been using sequelize migration all this while with no issue, for example in our development server:

"development": {
    "username": "root",
    "password": "password",
    "database": "db",
    "host": "127.0.0.1",
    "dialect": "mysql"
  }

using sequelize-cli will works fine:

npx sequelize db:migrate

results:

Sequelize CLI [Node: 12.16.1, CLI: 6.2.0, ORM: 6.3.5]

Loaded configuration file "config\config.json".
Using environment "development".
No migrations were executed, database schema was already up to date.

Same goes for our production server, which db is on different server than app:

"production": {
    "username": "root",
    "password": "password",
    "database": "db",
    "host": "172.xx.xx.11",
    "dialect": "mysql"
  }

So recently we have upgraded our production server to have 3 db servers using mariadb, managed by a load balancer (maxscale), a galera cluster or something, using the same setup as previous, so now its something like:

server a: 172.xx.xx.11, 
server b: 172.xx.xx.12, 
server c: 172.xx.xx.13, 
load balancer: 172.xx.xx.10

our new config is like:

"production": {
    "username": "root",
    "password": "password",
    "database": "db",
    "host": "172.xx.xx.10",
    "dialect": "mysql"
  }

there is no firewall open between app server and db server directly, only app server to the load balancer.

testing connection between app server and the load balancer with sequelize seems to have no issue, can pass through if username and password is correct, if wrong username, or wrong password will give

ERROR: Access denied for user 'root'@'172.xx.xx.10' (using password: YES)

no issue there. just saying that there is a connection.

then there is no issue also using:

npx sequelize db:drop

or

npx sequelize db:create

resulting in

Sequelize CLI [Node: 12.16.1, CLI: 6.2.0, ORM: 6.3.5]

Loaded configuration file "config\config.json".
Using environment "production".
Database db created.

Verifying in all our db servers that the database did dropped and created.

But when i tried doing migrations, this happens:

Sequelize CLI [Node: 12.16.1, CLI: 6.2.0, ORM: 6.3.5]

Loaded configuration file "config\config.json".
Using environment "production".

ERROR: Unknown database 'db'

I have verified that all our db servers did have that 'db' database, its even created by sequelize based on the config, but somehow sequelize cant seems to recognize or identified that 'db' database.

Please help if you have any experience like this before, and do let me know if you need more info. Thanks.

2

2 Answers

0
votes

You can enable the verbose log level in MaxScale by adding log_info=true under the [maxscale] section. This should help explain what is going on and why it is failing.

It is possible that Sequelize does something that assumes it's working with the same database server. For example, doing an INSERT and immediately reading the inserted value will always work on a single server but with a distributed setup, it's possible the values haven't replicated to all nodes.

If you can't find an explanation as to why it behaves like this or you think MaxScale is doing something wrong, please open a bug report on the MariaDB Jira under the MaxScale project.

0
votes

Turns out the maxscale user don't have enough privileges. granting SHOW DATABASES privileges to maxscale user fixed my issue.

more info: https://mariadb.com/kb/en/mariadb-maxscale-14/maxscale-configuration-usage-scenarios/#service

Related issue on MariaDB Jira