[MXS-1661] Excessive logging by MySQLAuth at authentication error (was: MySQLAuth SQLite database can be permanently locked) Created: 2018-02-08  Updated: 2020-08-25  Resolved: 2018-02-12

Status: Closed
Project: MariaDB MaxScale
Component/s: Authenticator
Affects Version/s: 2.1.13
Fix Version/s: 2.1.14, 2.2.2

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Johan Wikman
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MXS-1663 MaxScale should detect conflicting co... Closed
relates to MXS-1664 Add --runtimedir config parameter for... Closed

 Description   

A user reported that MaxScale is constantly reporting messages like the following:

2018-02-06 16:47:33   error  : [MySQLAuth] Failed to execute auth query: database is locked

It seems like their instance has gotten to the point where the SQLite database used for auth data is permanently locked. Here is a larger section of the log:

2018-02-06 16:47:32   error  : [MySQLAuth] Client hostname lookup failed, getnameinfo() returned: 'Name or service not known'.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:59938, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:59940, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:59942, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:59944, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:59946, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:59948, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.72]:48736, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.72]:48738, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.72]:48740, authentication failed.
2018-02-06 16:47:33   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.72]:48742, authentication failed. (subsequent similar messages suppressed for 10000 milliseconds)
2018-02-06 16:47:33   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:33   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:33   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:33   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:33   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:33   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:33   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:33   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:33   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:34   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table.
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked (subsequent similar messages suppressed for 10000 milliseconds)
2018-02-06 16:47:34   error  : [MySQLAuth] Failed to execute auth query: database is locked (subsequent similar messages suppressed for 10000 milliseconds)
2018-02-06 16:47:34   error  : [Splitter Service] Refresh rate limit exceeded for load of users' table. (subsequent similar messages suppressed for 10000 milliseconds)
2018-02-06 16:47:37   error  : [MySQLAuth] Client hostname lookup failed, getnameinfo() returned: 'Name or service not known'.
2018-02-06 16:47:42   error  : [MySQLAuth] Client hostname lookup failed, getnameinfo() returned: 'Name or service not known'.
2018-02-06 16:47:44   warning: [MySQLAuth] Splitter Service: login attempt for user 'user2'@[10.1.1.85]:34992, authentication failed.
2018-02-06 16:47:44   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:60052, authentication failed.
2018-02-06 16:47:44   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:60054, authentication failed.
2018-02-06 16:47:44   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.73]:60056, authentication failed.
2018-02-06 16:47:44   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.72]:48848, authentication failed.
2018-02-06 16:47:44   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.72]:48850, authentication failed.
2018-02-06 16:47:44   warning: [MySQLAuth] Splitter Service: login attempt for user 'user1'@[10.1.1.72]:48852, authentication failed.
2018-02-06 16:47:44   error  : [MySQLAuth] Failed to execute auth query: database is locked
2018-02-06 16:47:44   error  : [MySQLAuth] Failed to execute auth query: database is locked

Is this a bug, or is this a problem that is likely to happen under a certain scenario (e.g. a high rate of authentication failures or something like that)?



 Comments   
Comment by Johan Wikman [ 2018-02-09 ]

The database is locked indicates that two of MaxScale's worker threads simultaneously are trying to update the user database and it fails for either of them. It's the SQLITE_BUSY error explained here: https://sqlite.org/rescode.html#result_code_meanings

In the log above there are two users user1 and user2 for which the authentication fails and if they happen to be handled by two separate worker threads, then that could be an explanation.

Should the users user1 and user2 be able to access database? Can they, if MaxScale is not in between?

In MaxScale 2.2 database is locked can no longer occur as each worker thread has an in-memory user database of its own.

Comment by Johan Wikman [ 2018-02-09 ]

There are a couple of problems.

When the refresh rate limit has been exceeded, then every failed authentication will cause that message to be logged. It should be logged at most once, until we try refreshing the users again. That's straightforward to fix and will prevent the log from being flooded with messages.

Another thing is whether a failed authentication should at all trigger a refresh of the users. The idea is that if a user has been created, then if a failed authentication triggers a refresh of the users then MaxScale will automatically deal with new users. However, that leads to the problem here if there are logins with users who simply are not authorized. Perhaps it would be sufficient if MaxScale regularly (say once a minute, or 10 minutes) refreshes the users or perhaps not to refresh automatically at all but to provide a maxadmin/maxctrl command for doing it.

Comment by Johan Wikman [ 2018-02-09 ]

The database is locked errors are caused by running two maxscale instances in the same machine, without

--cachedir

having been defined to different value for the two instances. Without that, if those two instances have a service with the same name, they will end up using the very same sqlite database for the users. That then leads to the aforementioned error when they independently and concurrently try to update the database.

Comment by Johan Wikman [ 2018-02-12 ]

I'll rename this to Excessive logging by MySQLAuth at authentication error as the locking problem was caused by a user configuration error and the fixes that have been done addresses the excessive logging. There is now a task MXS-1663 that will prevent these kind of situations from occurring.

Comment by Johan Wikman [ 2018-02-12 ]

At startup, MaxScale loads all users from the backend. At runtime, when a user authentication fails, MaxScale assumes it is because a user has been created and reloads the users. During a time window of 30 seconds that could take place at most 4 times. Thereafter, each authentication failure caused a refresh rate exceeded error to be logged. If a client attempted to connect over and over again that would cause the log to be flooded until the flooding suppression mechanism hit in.

This has now been changed so that the users are refreshed at most once during that time window and an error about the refresh rate having been exceeded will also be logged at most once. Further, the length of the time window can now be adjusted using the global configuration option users_refresh_time using which the runtime refreshing also can be turned off entirely, if it is known that users are not created at runtime.

It is still possible to manually cause the users to be refreshed using maxadmin.

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