VocaDB/vocadb

/api/admin/audit-logs returns 500 (times out) when parameters "filter" and "userName" are used simultaneously

Shiroizu opened this issue · 0 comments

Website (required)

VocaDB

Describe the bug (required)

The audit log search times out when searching with both a text filter and an username:

https://vocadb.net/api/admin/audit-logs?filter=artist result in 486 ms
https://vocadb.net/api/admin/audit-logs?userName=Shiroizu result in 2780 ms
https://vocadb.net/api/admin/audit-logs?filter=artist&userName=Shiroizu no result, internal server error, status code 500

ViewSysLog:

2024-06-07 00:02:43.0144 [.NET ThreadPool Worker] ERROR Unexpected NHibernate error - NHibernate.Exceptions.GenericADOException could not execute query
[ select auditlogen0_.Id as id1_46_, auditlogen0_.[Action] as column2_46_, auditlogen0_.[AgentName] as column3_46_, auditlogen0_.[Time] as column4_46_, auditlogen0_.[User] as column5_46_, auditlogen0_.EntryType as entrytype6_46_, auditlogen0_.EntryId as entryid7_46_ from dbo.AuditLogEntries auditlogen0_ left outer join dbo.Users user1_ on auditlogen0_.[User]=user1_.Id left outer join dbo.UserOptions useroption2_ on user1_.Id=useroption2_.[User] where (auditlogen0_.[Action] like ('%'+@p0+'%')) and (auditlogen0_.[AgentName]=@p1 or useroption2_.[LastLoginAddress]=@p1) order by auditlogen0_.[Time] desc OFFSET @p3 ROWS FETCH FIRST @p4 ROWS ONLY ]
  Name:p1 - Value:artist  Name:p2 - Value:Shiroizu  Name:p4 - Value:0  Name:p5 - Value:200
[SQL: select auditlogen0_.Id as id1_46_, auditlogen0_.[Action] as column2_46_, auditlogen0_.[AgentName] as column3_46_, auditlogen0_.[Time] as column4_46_, auditlogen0_.[User] as column5_46_, auditlogen0_.EntryType as entrytype6_46_, auditlogen0_.EntryId as entryid7_46_ from dbo.AuditLogEntries auditlogen0_ left outer join dbo.Users user1_ on auditlogen0_.[User]=user1_.Id left outer join dbo.UserOptions useroption2_ on user1_.Id=useroption2_.[User] where (auditlogen0_.[Action] like ('%'+@p0+'%')) and (auditlogen0_.[AgentName]=@p1 or useroption2_.[LastLoginAddress]=@p1) order by auditlogen0_.[Time] desc OFFSET @p3 ROWS FETCH FIRST @p4 ROWS ONLY] System.Collections.IList DoList(NHibernate.Engine.ISessionImplementor, NHibernate.Engine.QueryParameters, NHibernate.Transform.IResultTransformer, NHibernate.Cache.QueryCacheResultBuilder)    at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters, IResultTransformer forcedResultTransformer, QueryCacheResultBuilder queryCacheResultBuilder)
   at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
   at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results, Object filterConnection)
   at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results)
   at NHibernate.Impl.AbstractSessionImpl.List[T](IQueryExpression query, QueryParameters parameters)
   at NHibernate.Impl.AbstractQueryImpl2.List[T]()
   at NHibernate.Linq.DefaultQueryProvider.ExecuteList[TResult](Expression expression)
   at NHibernate.Linq.NhQueryable`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at VocaDb.Model.Service.AdminService.<>c__DisplayClass15_0.<GetAuditLog>b__0(ISession session) in C:\Sites\VocaDB\web\VocaDbModel\Service\AdminService.cs:line 364
   at VocaDb.Model.Service.ServiceBase.HandleTransaction[T](Func`2 func, IsolationLevel isolationLevel, String failMsg) in C:\Sites\VocaDB\web\VocaDbModel\Service\ServiceBase.cs:line 262
SqlException Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. Void OnError(System.Data.SqlClient.SqlException, Boolean, System.Action`1[System.Action])
Win32Exception The wait operation timed out.

Checklist (required)

Fill out the checklist. Use strikethroughs or leave fields empty if you don't know or are unable to check/test.

  • Searched VocaDB/vocadb for duplicate issues.
  • Tested on the beta site. Works on beta site! Got response after 60+ secs.
  • [ ] Tested on different browsers (e.g. Firefox, Chrome, Safari, Edge).
  • [ ] Checked in private mode.
  • [ ] Cleared browser cache and cookies.
  • [ ] Checked the DevTools console.
  • Checked the syslog (mods+ only).