0

Not a duplicate, none of the proposed fixes solve my problem.

Adding requested information to reopen issue:

OS: Amazon Linux AMI release 2018.03

Java: 1.8 - more specifically on production it is OpenJDK build 1.8.0_201-b09

Spring Boot: 2.1.2.RELEASE

Database: AWS RDS MariaDB version 5.7.16

Here is the link to a gist containing the MySQL error log: https://gist.github.com/urielb/6675ec2a80f5fbca630e52ca0b9d2b2a

In the MySQL logs the only thing that appeared a lot before the crashing part I gisted above is this:

2019-07-11T19:26:18.888986Z 791 [Note] Aborted connection 791 to db: 'database' user: 'user' host: 'IP_ADDRESS' (Got an error reading communication packets)

But other than that, I couldn't find anything on the server logs.

END OF EDIT #2

This one has me scratching my head over the last couple days.

We have a Java Spring Boot application with access to a MySQL database.

We have an action that should save some data on the server, and some times it works fine, but other times it fails, but I still haven't been able to find a pattern on why it happens. Only happens in production.

There is no user input other then clicking a button, but when we try to get a connection to the database to perform the desired operations, the connection simple isn't made.

public static Connection getConnection()
{
    try
    {
        Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
        Connection conn = DriverManager.getConnection(Conf.getDatabaseConnectionString(), Conf.getDatabaseConnectionUser(), Conf.getDatabaseConnectionPassword());
        return conn;
    } catch (SQLException e)
    {
        logger.error("Failed to establish a connection to the database (SQLException): " + e.getMessage());
        return null;
    }
    ...
}

The connection string the same as below, except for pointing to the production server.

jdbc:mysql://localhost:3306/database?useSSL=false&allowPublicKeyRetrieval=false

That's basically the function except that there are more catches that check if it wasn't possible to make a connection, why was that, and returns a null.

So, the problem is, this method is often returning null. At first I thought it could be a 'TOO MANY ConnectionS' issue, but upon further inspection I realized that was not the case. Apparently it fails with a

...CJCommunicationsException: Communications link failure. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

But I really have no idea what may be causing this, why is this issue intermittent? I have no clue on where to begin to solve this problem. I've implemented a Hikari connection pool in hope it was only a case of too many connections.

I've read some articles suggesting some configurations on the MySQL server, specially regarding the listing address and ports, but using AWS RDS all we have to do is configure the security groups, also that wouldn't address the intermittency of the problem...

Anyone has ever experienced something similar? I am open to any ideas or suggestions at the moment.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Uriel Bertoche
  • 883
  • 2
  • 13
  • 23
  • Voting to reopen since the OP states that the solutions provided in the duplicate did not help. That said, this question could do with some updates: [1] Environment details: the versions of Java, Spring Boot, MySQL and the O/S of the production server. [2] Details of any messages in the O/S and MySQL logs at the times of the failures. If there really are no relevant messages in any of those logs then update the question to explicitly state that within the question. [3] While the error itself is intermittent, you may find a consistent pattern of error messages in those logs whenever it occurs. – skomisa Jul 11 '19 at 15:03
  • Additional information added with edit #2 – Uriel Bertoche Jul 11 '19 at 20:02

0 Answers0