[MXS-4527] Schemarouter reports "non-existent database" Created: 2023-02-23  Updated: 2023-06-30  Resolved: 2023-06-30

Status: Closed
Project: MariaDB MaxScale
Component/s: schemarouter
Affects Version/s: 22.08.4
Fix Version/s: 23.08.0

Type: Bug Priority: Major
Reporter: Bruno Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None
Environment:

debian 11/docker
mariadb on windows


Sprint: MXS-SPRINT-185

 Description   

I have two servers and one schemarouter service binded (+ listener and monitors).
If I try a connection with the user "web_xxxxx" to database "www.xxxx.com", the connection fails. The target server (I turned off the second as a test) is named "f01-r55". MaxScale reports:

.....
info   : <f01-r55, www.xxxx.srl, workflows>
 info   : <f01-r55, www.xxxx.com, workflowtypes>
 info   : <f01-r55, information_schema, >
 info   : <f01-r55, www.xxxx.com, >
 info   : Updated shard map for user 'web_xxxxf01-r55'
 info   : Connecting to a non-existent database 'www.xxxx.com'
 error  : Routing the query failed. Session will be closed.

So it performs shard map, can see that the requested DB exists, then it reports that database does not exist and refuse the connection

The settings seems working well, but it cannot process the request. Any idea?
thanks



 Comments   
Comment by Bruno [ 2023-02-28 ]

I performed many other tests. What I noticed is that the problem is when connection is started from a Drupal or a Concrete5 Website. If it is started from a Wordpress (same server), it works, and also if client is HeidiSQL.

I tried to force case insensitive in MaxScale (MariaDB is on Windows) but still nothing.

Comment by markus makela [ 2023-02-28 ]

So the problem is with the database names? The schemarouter should already treat table names case-insensitively:

Schemarouter compares table and database names case-insensitively. This means that the tables test.t1 and test.T1 are assumed to refer to the same table.

Comment by Bruno [ 2023-02-28 ]

I cannot find where the problem is, but sure it always reports that the database does not exist (reporting in error message, as database name, exactly the value used by client, and that it's right, and always all lowercase).
But if it works case-insensitively, that is good and cannot be a problem because my MariaDB runs on Windows and so it is case-insensitive.

A full "case insensitive" environment is what my clients are expecting, because they are used to connect directly to a MariaDB running on Win.

Comment by Bruno [ 2023-03-09 ]

I moved some databases from MariaDB on Win to MariaDB on docker (debian). The problem is the same:

  • if the client is wordpress, it works
  • if the client is Concrete5 or Drupal, maxscale reports that database does not exist
  • if the client is a custom app that is using PDO ( $conn = new PDO($col , "$db_user", "$db_psw") , MaxScale reports also that database does not exist

user and database are defined only on one server behind schemarouter

Comment by Bruno [ 2023-03-09 ]

I don't know if this can help, but if I execute

show schemas like 'www.domain.com';

connected to mariaDB, it reports only one row [that's ok]
If I run it connected to maxScale, it reports the list of every existing database in mariaDB [that's not ok and I didn't find it in MaxScale limitations list]

Also, in the first result HeidiSQL colors row as green (that means "text"), on the seconds rows are gold (that means "other" data type).

Other test using MaxScale GUI -> visualization:

  • if I connect to a "server", I can see databases and perform query on tables
  • if I connect with same users to "service" or "listener", I cannot see databases and performing query I get "unknown database" result

So the problem starts in service schemarouter

Also tried to create a new readconnroute + listener pointing to same server, and same database is accessible from visualization.

Comment by markus makela [ 2023-03-09 ]

I think it might be a bug in how the default database case-sensitiveness is handled.

Comment by Bruno [ 2023-03-10 ]

I noticed that WordPress, the only app working, starts PDO sessions with this code:

$this->mysql = new
PDO("mysql:dbname={$this->options['dbname']};host={$this->options['host']};port={$this->options['port']}",
$this->options['user'], $this->options['pass'],
array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));

so it assign as init command "SET NAMES utf8".

I suspect that the problem is not case related (I have only database name in lower case), but encoding related, and WP is "fixing" it with a good coding practice.

Comment by Bruno [ 2023-03-10 ]

I found that the problem is the ".", BOTH on database names and on users names.

When a database or a login contains a ".", MaxScale return always "database unknown".
Not in connection from WordPress.
"_" (I also have that in logins) seems not creating problems

Comment by markus makela [ 2023-03-10 ]

Ahh, it might be the . that is indeed the problem.

Comment by markus makela [ 2023-03-29 ]

I think this might already be fixed in the upcoming 23.08 release.

Comment by markus makela [ 2023-06-29 ]

This was partially fixed for 23.08 but required a minor fix to work correctly.

Generated at Thu Feb 08 04:29:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.