Answered by:
Failed to delete audit data from one or more of the specified partitions

Question
-
Hello,
I am using MS CRM 2011 ru 11 on premise and it is installed on SQL Server Standard edition i.e. I cannot delete the Audit Log partitions directly from CRM.
Hence, I have created a windows application:
// Get the list of audit partitions.
RetrieveAuditPartitionListResponse partitionRequest =
(RetrieveAuditPartitionListResponse)_service.Execute(new RetrieveAuditPartitionListRequest());
AuditPartitionDetailCollection partitions = partitionRequest.AuditPartitionDetailCollection;
// Create a delete request with an end date earlier than possible.
DeleteAuditDataRequest deleteRequest = new DeleteAuditDataRequest();
deleteRequest.EndDate = new DateTime(2000, 1, 1);
// Check if partitions are not supported as is the case with SQL Server Standard edition.
if (partitions.IsLogicalCollection)
{
// Delete all audit records created up until now.
deleteRequest.EndDate = DateTime.Now;
}
// Otherwise, delete all partitions that are older than the current partition.
// Hint: The partitions in the collection are returned in sorted order where the
// partition with the oldest end date is at index 0.
else
{
for (int n = partitions.Count - 1; n >= 0; --n)
{
if (partitions[n].EndDate <= DateTime.Now && partitions[n].EndDate > deleteRequest.EndDate)
{
deleteRequest.EndDate = (DateTime)partitions[n].EndDate;
break;
}
}
}
// Delete the audit records.
if (deleteRequest.EndDate != new DateTime(2000, 1, 1))
{
_service.Execute(deleteRequest);
Console.WriteLine("Audit records have been deleted.");
}
else
Console.WriteLine("There were no audit records that could be deleted.");When I run the application, I am receiving the following error:
"Failed to delete audit data from one or more of the specified partitions".
Please note that I have already extended the SQL Timeout from the web config and still receiving this error.
Any ideas?
Best Regards,
Joe Mouawad.
Monday, March 9, 2015 10:20 AM
Answers
-
I have fixed it, by deleting the audit logs on daily basis i.e. I have set a start date and an end date and the in the loop I delete the logs day by day.
Regards,
Joe Mouawad.
- Marked as answer by Joe Mouawad Thursday, March 12, 2015 11:17 PM
Thursday, March 12, 2015 11:17 PM
All replies
-
As a first step, enable tracing - this should give a more useful error
Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk
Monday, March 9, 2015 8:51 PMModerator -
I have fixed it, by deleting the audit logs on daily basis i.e. I have set a start date and an end date and the in the loop I delete the logs day by day.
Regards,
Joe Mouawad.
- Marked as answer by Joe Mouawad Thursday, March 12, 2015 11:17 PM
Thursday, March 12, 2015 11:17 PM -
Hello Joe,
I am also facing same issue in our CRM 2011 on premises version. Could you please elaborate more on what you did as a fix? Please reply.
Regards,
RahulWednesday, September 14, 2016 9:40 AM