Frequent data updates cause the SQL Server database to be locked and the client cannot access the database.

Source: Internet
Author: User
Introduction: The file upload function provides services using wcf, and the database is accessed using EntityFramework4. Symptom: There is a file block upload method in wcf. summary uploads the file. summaryparamnameblock file block information. paramreturns uploads the file information. Status: returnspublico

Introduction: The file upload function provides services using wcf, and the data library is accessed using EntityFramework4. Symptom: in wcf, there is a file block upload method // summary /// upload a file /// summary /// param name = "block" file block information/param /// returns upload File Information Status/returns public o

Introduction: file upload function, which is provided by wcfService,DataLibrary uses EntityFramework4Access.

Symptom: There is a file block upload method in wcf.

///


/// Upload a file
///
///File block information
/// Information Status of the uploaded file
Publicoverride FileTransportAck UpLoadFile (FileBlock block)
{
Lock (lockobj)
{
// Check whether the object exists
Tab_FileInfo theFileInfo = m_NetBidEnt.tab_FileInfo
. Where (o => o. FileID. Equals (block. FileID ))
. FirstOrDefault ();

If (theFileInfo = null)
Thrownew Exception ("file not initialized, Upload Failed ");

// Return the transmission result
FileTransportAck result = new FileTransportAck ();
// Write the file Block
If (FileSysIO. WriteBlock (theFileInfo, block ))
{
TheFileInfo. UploadedSize + = block. Size;
TheFileInfo. FileSize = block. Total;
TheFileInfo. UpdateDate = DateTime. Now;
M_NetBidEnt.SaveChanges ();
}
Else
Thrownew Exception ("failed to write the file block ");
// Write Return Value
Result. FileId = theFileInfo. FileID;
Result. Offset = (long) theFileInfo. UploadedSize;
If (theFileInfo. UploadedSize> = block. Total)
Result. TransportStat = FileTransportStat. Finished;
Else
Result. TransportStat = FileTransportStat. ResumeBreakPoint;
Return result;
}
}

This method will be called cyclically during file upload, basically every 10 K, that is, this will be calledAccessOne time, but the strange problem is that if the file is more than 10 MBStop.. ViewDataLibraryServiceOverallLike locking, ssms alsoNoConnection. All the exceptions reported are connection timeout.

Later, logs were added to the wcf method to record exceptions. The recorded exceptions are as follows:

Exception Message
2011-07-2800: 38: 26,451 An error occurred while starting a transaction on the provider connection. See the inner exception for details.
StackTrace
2011-07-2800: 38: 26,467 at System. Data. EntityClient. EntityConnection. BeginDbTransaction (IsolationLevel isolationLevel)
At System. Data. EntityClient. EntityConnection. BeginTransaction ()
At System. Data. Objects. ObjectContext. SaveChanges (SaveOptions options)
At System. Data. Objects. ObjectContext. SaveChanges ()
At NetBid. FileServices. Impl. FileSysFileService. UpLoadFile (FileBlock block)
At NetBid. FileServices. Wcf. FileServiceWCF. UploadFileBlock (FileBlock, Dictionary '2 parameters)
Inner Exception:
2011-07-2800: 38: 26,467 Inner Exception: System. data. sqlClient. sqlException (0x80131904): Timeout expired. the timeout period elapsed prior to completion of the operation or the server is not responding.
At System. Data. SqlClient. SqlInternalConnection. OnError (SqlException exception, Boolean breakConnection)
At System. Data. SqlClient. TdsParser. ThrowExceptionAndWarning ()
At System. Data. SqlClient. TdsParserStateObject. ReadSniError (TdsParserStateObject stateObj, UInt32 error)
At System. Data. SqlClient. TdsParserStateObject. ReadSni (DbAsyncResult asyncResult, TdsParserStateObject stateObj)
At System. Data. SqlClient. TdsParserStateObject. ReadNetworkPacket ()
At System. Data. SqlClient. TdsParserStateObject. ReadBuffer ()
At System. Data. SqlClient. TdsParserStateObject. ReadByte ()
At System. Data. SqlClient. TdsParser. Run (RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
At System. Data. SqlClient. TdsParser. Handle (Byte [] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)
At System. Data. SqlClient. SqlInternalConnectionTds. ExecuteTransactionYukon (TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
At System. Data. SqlClient. SqlInternalConnectionTds. ExecuteTransaction (TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
At System. Data. SqlClient. SqlInternalConnection. BeginSqlTransaction (IsolationLevel iso, String transactionName)
At System. Data. SqlClient. SqlInternalConnection. BeginTransaction (IsolationLevel iso)
At System. Data. SqlClient. SqlConnection. BeginDbTransaction (IsolationLevel isolationLevel)
At System. Data. Common. DbConnection. BeginTransaction (IsolationLevel isolationLevel)
At System. Data. EntityClient. EntityConnection. BeginDbTransaction (IsolationLevel isolationLevel)
2011 to 07-2800: 38: 26,467 ============================================== ====================== split line

The exception looks like a transaction problem, but there is a strange phenomenon:StopAfter the phenomenon, the entireDataKuduNoAccess, You can onlyDataLibraryServiceStopAnd restart.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.