Xwiki privileges problem in MySQL

This is a “known” issue and I read through several threads including the docs but I can’t solve it.

I first met the Access denied for user 'xwiki'@'%' to database 'testsubwiki' when trying to create a sub wiki. Everything else was working nicely before. So I found in the docs this page: https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/InstallationWAR/InstallationMySQL/ which shows how to grant access.

I did all this in our database and finally I was able to create sub wikis.

Today I was presented a white page from the XWiki service and found out that around 4am this morning XWiki crashed with a Java Heap Memory error which turned out to be caused by a huge log-spam saying

km3net-wiki_web.1.5g1xoj6qwcnwmg3ebbb6928mv@pi1085 | Caused by: java.sql.SQLException: Access denied for user 'xwiki'@'10.0.13.46' (using password: YES)

I don’t understand how this is possible, since to my knowledge, the user xwiki has all privileges, no matter on from which host it is operating (we are running in a swarm, so the host may change any time):

mysql> SHOW GRANTS FOR xwiki;
+--------------------------------------------------+
| Grants for xwiki@%                               |
+--------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'xwiki'@'%'       |
| GRANT ALL PRIVILEGES ON `xwiki`.* TO 'xwiki'@'%' |
| GRANT ALL PRIVILEGES ON `%`.* TO 'xwiki'@'%'     |
+--------------------------------------------------+
3 rows in set (0.00 sec)

Any ideas?

I am still not able to run it with subwikis. The other XWiki instance is running fine with the very same configuration in our Docker Swarm.

Only the XWiki instance where we created a subwiki is completely broken.

Does anybody have an idea?

Here is the full error which is spammed multiple times in a second until the service crashes due to full memory:

km3net-wiki_web.1.idiirptwuy2fymx9pzf5r8xco@pi1085    | 2021-11-08 08:57:13,737 [XWiki initialization] ERROR c.x.x.s.DBCPConnectionProvider - Could not create a DBCP pool. There is an error in the Hibernate configuration file, please review it.
km3net-wiki_web.1.idiirptwuy2fymx9pzf5r8xco@pi1085    | java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'xwiki'@'10.0.13.54' (using password: YES))

As said, to my understand the xwiki user has all rights to do everything from all hosts.