插入包含blob字段的记录时,blob数据超过一定大小(小于max_allowed_packet)时提交一段时间后报错如下:
2021-03-02 13:44:59.392 [http-nio-auto-1-exec-10] WARN com.zaxxer.hikari.pool.ProxyConnection - HikariPool-1 - Connection com.mysql.cj.jdbc.ConnectionImpl@127bc78a marked as broken because of SQLSTATE(08S01), ErrorCode(0) com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet successfully received from the server was 3,053 milliseconds ago. The last packet sent successfully to the server was 3,056 milliseconds ago. at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure The last packet successfully received from the server was 3,053 milliseconds ago. The last packet sent successfully to the server was 3,056 milliseconds ago. at jdk.internal.reflect.GeneratedConstructorAccessor78.newInstance(Unknown Source) Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. at com.mysql.cj.protocol.FullReadInputStream.readFully(FullReadInputStream.java:67) 2021-03-02 13:44:59.392 [http-nio-auto-1-exec-10] WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 08S01 2021-03-02 13:44:59.392 [http-nio-auto-1-exec-10] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Communications link failure The last packet successfully received from the server was 3,053 milliseconds ago. The last packet sent successfully to the server was 3,056 milliseconds ago. 2021-03-02 13:44:59.398 [http-nio-auto-1-exec-10] ERROR o.a.c.c.C.[.[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: could not execute statement; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute statement] with root cause java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. at com.mysql.cj.protocol.FullReadInputStream.readFully(FullReadInputStream.java:67)
查看MYSQL日志,发现服务自动重启
解决: 虽然容器内存负载并不高,但是增加容器负载内存配额后可以解决问题,提交更大的BLOB数据需要进一步增加内存配额,细节待查