Score:0

Is it possible that MariaDB caches the host depending on user and password?

in flag

I have a weird issue with my MariaDB in my application.

I use Prisma NodeJS library to connect to MariaDB.

The problem looks like this:

I have localhost and a remote server with the same username/password/database combination (to make it easier for me and not need to change configuration)

  1. I have a URL string with user, password, host, and database
  2. When I change the host to my remote server it still read localhost database
  3. If I change the password locally (my CLI) it reads the remote server
  4. The same if I change the password on the server and update the URL string

Is it possible that MariaDB saves the user/password/database in some kind of cache and takes a host based on that cache?

I use Fedora GNU/Linux 37 and MariaDB 10.5.18

Is this a bug in MariaDB should I report it somewhere?

I've asked about this on Prisma discussion page on GitHub

EDIT: These are my URL strings:

  1. DATABASE_URL="mysql://10669_koduj_quiz:<PASSWD>@localhost:3306/10669_koduj_quiz"
  2. DATABASE_URL="mysql://10669_koduj_quiz:<PASSWD>@jcubic.atthost24.pl:3306/10669_koduj_quiz"

NOTE: It's obvious from my experimentation that the URL is cached but I'm not sure who is responsible for this. MariaDB, Prisma package, an NPM library that is used to connect to MySQL, or maybe there is some shared library on my system that is used by NodeJS library.

ua flag
I don't think there is caching. Please provide the URL strings, etc that you are trying (but with the pwd masked out).
jcubic avatar
in flag
@RickJames added the strings, in one scenario I just changed the host, and that change is ignored when user/pass/db is the same.
Score:2
ca flag

MariaDB does not cache host connections. However, an already open connection remain open and working if the host (or user, or password) info changes but the connection is not terminated. This means that if you have an open connection and you change the host/user/password without terminating that connection, it remains active and you can use it for querying/updating your DB.

In other words, host/user/password information are checked on connection establishment, not during querying.

So it is possible that the used framework/library is not closing your connection (ie: implementing a form of connection pooling and/or other optimizations).

jcubic avatar
in flag
But I killed the app that used the connection. It's impossible to keep the connection open if the app is closed, isn't it?
shodanshok avatar
ca flag
It really depends on the specific application/framework. You can do a simple test by changing host/user/password and then trying to open a new connection via `mysql` command line. It should obey the newly changed settings.
jcubic avatar
in flag
But MySQL CLI doesn't use the same connection string as my application
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.