When releasing a connection from the SQL connection pool, and SQL exception may cause the connection to never be read/write again.
The offending code is in org.fcrepo.server.storage.ConnectionPool where this method is:
Note that on any exception it is never tried again to change the mode of the connection. And since the default is that connections are read only in the pool, the connection will never again be read/write.
The log message is erronous too, it seems to claim that the problem is in setting a connection read only, but it might as well be in setting it read write.
This may happen in a real world scenario, where the exception you try to set to readWrite or readOnly is closed. You will get an exception with "connection is closed". You will have this scenario if you call free twice:
because free tries to set the connection to readOnly.
We think this happens if an SQL query is expired, while still delivering data. The connection will then be freed twice: First when expired, second when the result is finally ready.
We have had this situation happen to us twice in 24 hours, and it makes Fedora unwritable but responsive to reads.