Inserting record in Azure Table Storage in a multi-threaded environment

by Euo 21. July 2010 17:48

 You might experienced this error while trying to insert records in Table Storage in a multi threaded environment. What you can do is to make it synchronous access in the TableServiceDataContext's AddObject and SaveChanges portion of your code. 

  lock (_lockable)
            {
                this.AddObject("MonitoringEntries", entry);
                this.SaveChanges();
            }

"An error occurred while processing this request."
    [System.Data.Services.Client.DataServiceRequestException]: "An error occurred while processing this request."
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: null
    InnerException: "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n  <code>EntityAlreadyExists</code>\r\n  <message xml:lang=\"en-US\">The specified entity already exists.\nRequestId:a01504ea-50e2-4e03-ae9e-1b3deefcc529\nTime:2010-07-21T09:47:19.7159778Z</message>\r\n</error>\r\n"
    Message: "An error occurred while processing this request."
    Source: "System.Data.Services.Client"
    StackTrace: "   at System.Data.Services.Client.DataServiceContext.SaveAsyncResult.HandleBatchResponse()\r\n   at System.Data.Services.Client.DataServiceContext.SaveAsyncResult.EndRequest()\r\n   at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)\r\n   at System.Data.Services.Client.DataServiceContext.SaveChanges()\r\n   at

...
    TargetSite: {Void HandleBatchResponse()}

Tags:

Cloud Computing | Development

About the author

Something about the author

Month List

Page List