java.sql.SQLException: Operation not allowed after ResultSet closed when using Slick 1.0.1

StackOverflow https://stackoverflow.com/questions/22619361

  •  20-06-2023
  •  | 
  •  

Question

This is probably going to be a horrible SO question since very little information can be given. Pretty much we're getting a java.sql.SQLException: Operation not allowed after ResultSet closed at, what it seems like, random times when using Slick 1.0.1 with MySQL.

I looked up this exception and it seems that the reason why it happens is because an ResultSet is being either closed prematurely or multiple ResultSets are being made from the same Statement object (see Getting java.sql.SQLException: Operation not allowed after ResultSet closed).

Now the issue is that I'm using Slick, so the whole idea of a ResultSet is abstracted away. I can't really show you any code since I have no idea where the issue is happening (the stack trace points to different parts of the code whenever it happens. Pretty much, at a random part of the code where it tries to access the DB, it would fail).

Not really doing anything crazy, just withSession's and withTransaction's and Session.withTransaction's. C3P0 is providing the connections.

We have been able to notice that is happens in 3 calls. What these 3 calls have in common is that they are some-what long running (they make about 3-5 calls to the DB, all within the same session. Is this bad?).

Has anyone seen this sort of error in Slick 1.0.1? I'm aware that there is a Slick 2.0 out but we are not ready to upgrade to that just yet (unless someone tells me this is a bug fixed in 2.0).

Thanks.

EDIT: Some more info about:

SHOW VARIABLES LIKE '%_timeout'; enter image description here

Some info on the 3 calls:

call 1:

  • 3 to 5 reads (2 reads are optional)
  • 2 writes

call 2:

  • 4 reads (I've just noticed, these are 4 big reads. Spanning several joins)
  • No writes

call 3 (just noticed that this call's number of failures has decreased lately):

  • 2 reads
  • 2 writes
Was it helpful?

Solution

Thanks to @Steve Waldman for the answer. The issue was with C3PO. The setting unreturnedConnectionTimeout is very, very bad (I somehow missed the warning in the documentation: http://www.mchange.com/projects/c3p0/#unreturnedConnectionTimeout). Getting rid of this configuration fixed the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top