Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIKARI maxLifetime vs MariaDB wait_timeout #736

Closed
3 of 4 tasks
MysticJay opened this issue Jan 15, 2022 · 4 comments
Closed
3 of 4 tasks

HIKARI maxLifetime vs MariaDB wait_timeout #736

MysticJay opened this issue Jan 15, 2022 · 4 comments

Comments

@MysticJay
Copy link

MysticJay commented Jan 15, 2022

Checklist

  • I checked other issues already, but found no answer/solution
  • I checked the documentation and wiki, but found no answer/solution
  • I am running the latest version and the issue still occurs
  • I am sure that this issue is about SteVe (and not about the charging station software or something unrelated to SteVe)

Specifications

SteVe Version     : 3.4.5 Docker. (I have questions about the upgrade procedure and Log4J is not important here)
Operating system  : QNAP QTS 4.5.4 with 
JDK               : ? as in the Docker created form docker-compose.yml
Database          : MariaDB 10 from the generated Docker

in the logs I find this:

{"log":"[WARN ] 2022-01-15 09:01:09,333 com.zaxxer.hikari.pool.PoolBase (qtp247162961-374) - HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@2826e648 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.\n","stream":"stdout","time":"2022-01-15T09:01:09.334185851Z"}

The advise found in Google is that the connection is terminated from MariaDB within 600 sec, while the value maxLifetime is bigger than those 600s. maxLifetime (in ms) should be set to 590000 to have a smaller value and force SteVe to reconnect before trying again.
(https://stackoverflow.com/questions/46830159/hikari-failed-to-validate-connection-because-connection-is-closed)

you may also check here:
https://joshefin.xyz/mariadb-hikaricp-and-connection-lifetime/
spring.datasource.hikari.max-lifetime = 580000

Where should this value be configured?

@MysticJay
Copy link
Author

Proposal for BeanConfiguration.java:
after:

        SteveConfiguration.DB dbConfig = CONFIG.getDb();

        HikariConfig hc = new HikariConfig();

        // set standard params
        hc.setJdbcUrl("jdbc:mysql://" + dbConfig.getIp() + ":" + dbConfig.getPort() + "/" + dbConfig.getSchema());
        hc.setUsername(dbConfig.getUserName());
        hc.setPassword(dbConfig.getPassword());

add
hc.setMaxLifetime (580000);
hope that's it (sorry, I am not familiar with anything in this project, so for the time being I will not create a PR for this one-line fix)

M.

@skullmonkey911
Copy link

Hi,

I have the same issue as MysticJay describes.

I've two questions about it:

  1. @MysticJay : Is it working for you with this config?
  2. @goekay : Is this workarround sound in your point of view?

Kind regards,

Stephan

@goekay
Copy link
Member

goekay commented Mar 3, 2022

hey all, thanks for bringing this up. i understand the problem and am okay with the suggested solution. i will make the changes shortly.

goekay added a commit that referenced this issue Mar 4, 2022
@goekay
Copy link
Member

goekay commented Mar 7, 2022

referenced commit addresses the issue, and i am therefore closing it

@goekay goekay closed this as completed Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants