User login trigger launching script repeatedly?

Since I’ve been focused on logging the last few days, I’ve added a script that logs user login events.
This script is triggered by the User Login trigger, as shown below.

As soon as I enable this trigger, it launches the script repeatedly, regardless of what’s in the script - even if it just sets a variable and doesn’t log anything. The Universal.Server process then proceeds to consume as much memory as it can - I enabled the trigger and within ten minutes it’s up to 7GB and climbing, when normally it settles well below 2GB.

New-PSUTrigger -Name “User Login” -EventType “UserLogin” -Environment “Integrated” -TriggerScript “Write-LogUserLoginEvent.ps1”

This is my environment config:

New-PSUEnvironment -Name “Integrated” -Version “7.1.4” -Path “Universal.Server” -Modules @(‘ActiveDirectory’, ‘Xibo’, ‘Nagios’, ‘PSFramework’) -Variables @(’*’) -StartupScript @(‘Logging\Set-LoggingOptions.ps1’) -HighPerformanceRunspacePool

I also noticed that the log has a whole bunch of errors as well:

2022-03-24 14:23:33.593 -03:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at LiteDB.Engine.LockService.EnterTransaction()
   at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
   at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
   at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
   at LiteDB.LiteQueryable`1.ToDocuments()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<<ExecutePowerShell>b__5>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 610
2022-03-24 14:23:33.593 -03:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at LiteDB.Engine.LockService.EnterTransaction()
   at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
   at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
   at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
   at LiteDB.LiteQueryable`1.ToDocuments()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<<ExecutePowerShell>b__5>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 610
2022-03-24 14:23:33.593 -03:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at LiteDB.Engine.LockService.EnterTransaction()
   at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
   at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
   at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
   at LiteDB.LiteQueryable`1.ToDocuments()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<<ExecutePowerShell>b__5>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 610
2022-03-24 14:23:33.594 -03:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at LiteDB.Engine.LockService.EnterTransaction()
   at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
   at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
   at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
   at LiteDB.LiteQueryable`1.ToDocuments()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<<ExecutePowerShell>b__5>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 610
2022-03-24 14:23:33.593 -03:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at LiteDB.Engine.LockService.EnterTransaction()
   at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
   at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
   at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
   at LiteDB.LiteQueryable`1.ToDocuments()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<<ExecutePowerShell>b__5>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 610
2022-03-24 14:23:33.593 -03:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at LiteDB.Engine.LockService.EnterTransaction()
   at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
   at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
   at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
   at LiteDB.LiteQueryable`1.ToDocuments()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<<ExecutePowerShell>b__5>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 610
2022-03-24 14:23:33.593 -03:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at LiteDB.Engine.LockService.EnterTransaction()
   at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
   at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
   at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
   at LiteDB.LiteQueryable`1.ToDocuments()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<<ExecutePowerShell>b__5>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 610
2022-03-24 14:23:33.594 -03:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at LiteDB.Engine.LockService.EnterTransaction()
   at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
   at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
   at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
   at LiteDB.LiteQueryable`1.ToDocuments()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<<ExecutePowerShell>b__5>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 610

Product: PowerShell Universal
Version: 2.9.2

I should also mention, the script I have it triggering is inside a folder, and when viewing the trigger in the UI it doesn’t show the script name, but editing the trigger does display it.

Whoa. What kind of authentication are you using?

Windows Auth

1 Like

I just tried this again on 2.11 and it seems to still be present there, definitely not pressing but still pretty weird

I should have opened an issue for this. Sorry about that: User login trigger launching script repeatedly · Issue #1172 · ironmansoftware/issues · GitHub

1 Like

@StuartA - Side question but do you care to share what your loginEvent.ps1 script looks like? If not totally understandable :slight_smile:

Sure, there’s really not much to it, I’m leveraging the PSFramework module for logging in my environment and this just writes to it.

$LogName = 'platform_Login_event'
Write-PSFMessage -Level Host -FunctionName $LogName -Message $Data.UserName -Tag $RemoteIPAddress
1 Like