Confluence. Error while uploading attachment. java.lang.RuntimeException: There was a problem evicting or flushing an AttachmentData object
Asked by Alex Kiselev _Itransition_:

confluence 4.3 + mysql 5.5 + apache 2.2 on windows server 2008 r2  

Attachment storage = database  

Attachment max size = 20.00 MB  

There is a reqular and from time to time reproducible problem (but sometimes it's uploaded correctly) while uploading pdf file about 900kb:  

<br />

System Error  

A system error has occurred --- our apologies!  

For immediate troubleshooting, consult our knowledge base for a solution.  

If you would like to receive support from Atlassian's support team, ask your Confluence administrator to create a support issue on Atlassian's support system with the following information:  

a description of your problem and what you were doing at the time it occurred  
a copy of the error and system information found below  
a copy of the application logs (if possible).  

Your Confluence administrator can use the support request form to create a support ticket which will include this information.  

We will respond as promptly as possible.  
Thank you!  

Return to site homepage...  
Cause  

java.lang.RuntimeException: There was a problem evicting or flushing an AttachmentData object:  
at com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateAttachmentDataDao.save(HibernateAttachmentDataDao.java:68)  

caused by: net.sf.hibernate.exception.GenericJDBCException: could not insert: \[com.atlassian.confluence.pages.AttachmentData#8323583\]  
at net.sf.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:90)  

caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 47 milliseconds ago. The last packet sent successfully to the server was 47 milliseconds ago.  
at sun.reflect.GeneratedConstructorAccessor605.newInstance(Unknown Source)  

caused by: java.net.SocketException: Connection reset by peer: socket write error  
at java.net.SocketOutputStream.socketWrite0(Native Method)


Answers:
author: Septa Cahyadiputra
body: Hi Alex,

It is quite difficult to pin point the cause of the issue with only partial stack trace to review. However this particular line:

```
caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 47 milliseconds ago. The last packet sent successfully to the server was 47 milliseconds ago.at sun.reflect.GeneratedConstructorAccessor605.newInstance(Unknown Source)
```

Seems to indicate that Confluence was not able to connect to your database in the process of attaching the attachment due to communication failure. We highly recommend you to review our [documentation](https://confluence.atlassian.com/display/CONFKB/Confluence+Slows+and+Times+Out+During+Periods+of+High+Load+Due+to+DB+Connection+Pool) and see if the provided resolution help stabilize your database.

Hope it help.

Cheers,  
Septa Cahyadiputra

comments: author: Alex Kiselev _Itransition_
body: Thanks for your reply.

There are lots of suggestions in common on link provided. Could you help to find out the particular reason of the problem, then I'll be able concentrate on it.

I did follow recommendations step 4:

threads from conf\\server.xml

maxProcessors="75" enableLookups="false" redirectPort="8443" acceptCount="10" debug="0" connectionTimeout="20000"

db connections from cfg.xml

\<property name="hibernate.c3p0.max_size"\>60\</property\>  
\<property name="hibernate.c3p0.max_statements"\>0\</property\>  
\<property name="hibernate.c3p0.min_size"\>0\</property\>  
\<property name="hibernate.c3p0.timeout"\>30\</property\>

And the problem soon had been reproduced


author: Septa Cahyadiputra
body: Again, it would be difficult to pin point without the rest of the data and the mentioned additional information. HOwever for a start you can try to increase the max connection as mentioned on steps 4


Tags: attachment

confluence-administration