I am trying to load a date range for audit data, however, it keeps saying no data found. Also, when I try to do a large age (last 500 days), it says completed but only loads the most recent log. When adding new date ranges, I usually get the error below "cannot insert duplicate key".
Question
Question
Audit Trail Not Loading Audit Data for Reporting
Replies
I ran into this problem as well. The only way I could get around it was by creating a new Audit Trail reporting database.
I've experienced this problem as well. It seems to happen when I attempt to load data over a date range that may have been loaded or partially loaded previously. I receive a similar error in the event log on the Audit Trail server:
An error occurred:
ERROR [23000] [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Violation of UNIQUE KEY constraint 'audit_date_range_unq'. Cannot insert duplicate key in object 'dbo.audit_date_range'. The duplicate key value is (bf6acf6e-1687-4f9b-9e85-36473f49de04, 4265b479-a8c9-43a9-8174-15e26a7e919c).
ERROR [01000] [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]The statement has been terminated. at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
at AuditDBService.Importer.<>c__DisplayClass15_0.<CheckForNewJobs>b__0(OdbcCommand cmd)
at Laserfiche.Catalyst.RetriableDbOperations.DbRetriableOperation`3.<>c__DisplayClass4`1.<Invoke>b__3(TDbConnection dbConnection)
at Laserfiche.Catalyst.RetriableDbOperations.DbRetriableOperation`3.<>c__DisplayClassa`1.<Invoke>b__9()
at Laserfiche.Catalyst.RetriableDbOperations.DbAwsRetryStrategy.Invoke[TResult](Func`1 func)
at Laserfiche.Catalyst.RetriableDbOperations.DbRetriableOperation`3.InvokeRetriableOperation[TResult](Func`1 func)
at AuditDBService.Importer.ImportLogs()
Since I've deleted and re-created the Audit Trail database before, I decided to play around with the database itself before destroying it this time. I deleted everything from the [dbo].[audit_date_range] table, and I was able to get the audit data to load without the above issue. The reporting works. I don't know if I have duplicate records, but things look okay from a glance. I don't know what other impact this had, but it makes me wonder if the constraint on the [dbo].[audit_date_range] table is necessary, or if it's being processed at appropriately during the load process?