DAQEM / GriefLogger

A fast Minecraft mod that uses SQLite or MySQL to log player interactions.
https://daqem.com
Apache License 2.0
6 stars 5 forks source link

Add MySQL autoreconnect #29

Open KamushekDev opened 7 months ago

KamushekDev commented 7 months ago

Sometimes server is empty and there are no players thus no actions are performed. After some time there are exceptions in logs even after I tried to add mysqlDatabase = "database_name?autoReconnect=true&wait_timeout=31536000" in config. Would appreciate the ability to configure these parameters alongside others.

[04Mar2024 21:17:27.062] [GriefLogger thread/ERROR] [com.daqem.grieflogger.GriefLogger/]: Failed to execute statements
com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 249,037,137 milliseconds ago. The last packet sent successfully to the server was 249,037,141 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:175) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1009) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1320) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:994) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.daqem.grieflogger.database.Database.executeStatements(Database.java:97) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.daqem.grieflogger.database.queue.Queue.execute(Queue.java:33) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.daqem.grieflogger.event.TickEvents.lambda$registerEvents$1(TickEvents.java:29) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.82.Final.jar%2382!/:4.1.82.Final]
    at java.lang.Thread.run(Thread.java:840) ~[?:?]
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: The last packet successfully received from the server was 249,037,137 milliseconds ago. The last packet sent successfully to the server was 249,037,141 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at jdk.internal.reflect.GeneratedConstructorAccessor99.newInstance(Unknown Source) ~[?:?]
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
    at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:62) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:150) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:166) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.protocol.a.NativeProtocol.clearInputStream(NativeProtocol.java:870) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.protocol.a.NativeProtocol.sendCommand(NativeProtocol.java:682) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket(NativeProtocol.java:1052) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.NativeSession.execSQL(NativeSession.java:657) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:893) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    ... 11 more
Caused by: java.io.IOException: Socket is closed.
    at com.mysql.cj.protocol.AbstractSocketConnection.getMysqlInput(AbstractSocketConnection.java:73) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.protocol.a.NativeProtocol.clearInputStream(NativeProtocol.java:866) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.protocol.a.NativeProtocol.sendCommand(NativeProtocol.java:682) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket(NativeProtocol.java:1052) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.NativeSession.execSQL(NativeSession.java:657) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:893) ~[grieflogger-1.1.4-forge.jar%23186!/:?]
    ... 11 more