I get the following error when trying to attach a file to any business object in both the desktop and web client.
"Error writing chunk of attachment. Error while preforming query."
My application server is on a separate server from my SQL database server. This error is not occurring on my test or sandbox server which share the same database server as production.
Here are the errors found in the logs of the production application server.
The correlationID of this exception is '9434d2a1569f8f40d4ae5c44bfa2427151e564967f'. Exception occured while runnging query for SqlServerEngineSpecificHelper::WriteNextAttachmentChunkForVarBinaryMaxField. The text of the Query was 'UPDATE [dbo].[TrebuchetAttach] SET FileContents .WRITE(@P1,@P2,@P3) WHERE (RecID = @P4)'.
[System.Data.SqlClient.SqlException] Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
[System.ComponentModel.Win32Exception] The wait operation timed out [Stack trace not available.]
Message: Error writing chunk of attachment
[Trebuchet.TrebuchetSqlDbException] Error while performing query. See server logs for details. CorrelationID 9434d2a1569f8f40d4ae5c44bfa2427151e564967f.
at Trebuchet.Database.BaseEngineHelper.BaseExecute[TReturn](Func`1 serviceExecFunc, String methodName, String queryText, String logQueryTypeMessage, String logMessageNameForResult, DebugCategory debuggerCategory)
at Trebuchet.Database.BaseEngineHelper.RunExecuteNonQuery(IDbCommand command, String methodName)
at Trebuchet.Database.SqlServerEngineSpecificHelper.WriteNextAttachmentChunkForVarBinaryMaxField(String strTableName, IDbConnection conn, BinaryChunkInfo info)
Message: WCF exception
[Trebuchet.TrebuchetDbException] Error writing chunk of attachment
at Trebuchet.Database.SqlServerEngineSpecificHelper.WriteFirstAttachmentChunkForVarBinaryMaxField(String strTableName, IDbConnection conn, String strFilePath, String strFileExt, Byte bytesToWrite, AttachTableStorageType atst)
at Trebuchet.Database.SqlServerEngineSpecificHelper.WriteFirstAttachmentChunk(String strTableName, IDbConnection conn, String strFilePath, String strFileExt, Byte bytesToWrite, AttachTableStorageType atst)
at Trebuchet.Database.AttachmentDbAccessor.WriteFirstAttachmentChunk(String tableName, String filePath, String fileExtension, Byte bytesToWrite, AttachTableStorageType atst)
at Trebuchet.Database.AttachmentDbAccessor.WriteFirstAttachmentChunk(String filePath, String fileExtension, Byte bytesToWrite, AttachTableStorageType atst)
The error you are receiving appears to be a database timeout: [System.Data.SqlClient.SqlException] Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
It would be worth setting the Database Timeouts to “No Limit” and testing again. Defaults are 30sec/60sec I believe, and can be set through a new Blueprint > Tools > Options > Database.
If this does not help your issue please log a ticket with support and they can work with you on other options. Thanks!
Just a note - I ran into this issue when upgrading from V9.0.1 to 9.1.1;
The solution was to manually change the TrebuchetAttach.FileContents column from type 'varbinary(MAX)' to 'image'. This happened with Reports as well
Hi Doug, you were able to just change the column type directly in the table (modify and hit Save)? And how does "image" cover all the different types of attachments there could be in Cherwell (Office, .Pdf, Image, etc.)?
I don't remember anymore, exactly what was required to change the column type, it was fairly quick so I believe it was fairly simple to change, but I could be wrong;
The 'Image' data type in SQL is not the same as what you or I would consider to be an 'image' file type; It is essentially just a data type in SQL for storing binary/file data I believe (so essentially, that's describing the type of data, a binary 'image' describing a file, rather than the type of a file itself... Kind of the way .ISO files are referred to as a binary 'image' of a disk's contents - Don't worry about it, it can contain any kind of file as it's just a data type rather than describing the file extension being used here like PNG JPEG etc)
Definitely try this out on a dev environment / sandbox, just in case you run into any kind of data loss when attempting to test this update