Page 1 of 2

Main Thread Fatal Error

Posted: Thu 27 Feb 2014, 17:14
by cyberde
Hi,

I've come across an error that has happened to me a couple of times now which kills all switchking services.
It seems like it happens when changing system modes, I have posted the log, around the time of the error, below for your information :)

Code: Select all

{BusinessAccess - Devices} --<Warning> -- 2014-02-27 15:56:05 -- ScheduleMode with id 3 is bound to an nonexisting schedule.
{BusinessAccess - Invocation} --<Warning> -- 2014-02-27 15:56:05 -- Device with id 30, name [LIVINGROOM] Light Curtain front, native id 31 and code 4:9 is defaulting to state off due to that the device is not tied to an active schedule or that the schedule could not be used to calculate an expected state. This is a warning only, and can be discarded if this device is intended to be controlled manually.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:05 -- Device with id 16, name [HALLWAY1ST] Shutter (Door), native id 17 and code 5:3 has a nonmatching state.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:05 -- Device with id 19, name [LIVINGROOM] Shutter (Window-back), native id 20 and code 4:2 has a nonmatching state.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:05 -- Device with id 21, name [LIVINGROOM] Shutter (Backdoor), native id 22 and code 4:3 has a nonmatching state.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:06 -- Device with id 16, name [HALLWAY1ST] Shutter (Door), native id 17 and code 5:3 is being turned on. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:06 -- Telldus API TurnOn responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:07 -- Device with id 19, name [LIVINGROOM] Shutter (Window-back), native id 20 and code 4:2 is being turned on. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:08 -- Telldus API TurnOn responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:08 -- Device with id 21, name [LIVINGROOM] Shutter (Backdoor), native id 22 and code 4:3 is being turned on. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:09 -- Telldus API TurnOn responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:10 -- Device with id 9, name [BATHROOM] Ceiling, native id 3 and code 2:1 is being turned off. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:11 -- Telldus API TurnOff responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:11 -- Device with id 9, name [BATHROOM] Ceiling, native id 3 and code 2:1 is being turned off. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:12 -- Telldus API TurnOff responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:13 -- Device with id 9, name [BATHROOM] Ceiling, native id 3 and code 2:1 is being turned off. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:13 -- Telldus API TurnOff responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:14 -- Device with id 9, name [BATHROOM] Ceiling, native id 3 and code 2:1 is being turned off. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:15 -- Telldus API TurnOff responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:16 -- Device with id 9, name [BATHROOM] Ceiling, native id 3 and code 2:1 is being turned off. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:17 -- Telldus API TurnOff responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:18 -- Device with id 17, name [BEDROOM] Bedlight, native id 18 and code 1000000100 is being turned off. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:18 -- Telldus API TurnOff responded with: 0
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:19 -- Device with id 17, name [BEDROOM] Bedlight, native id 18 and code 1000000100 is being turned off. Method used is TellStickWrapper.
{BusinessAccess - Invocation} --<Status> -- 2014-02-27 15:56:19 -- Telldus API TurnOff responded with: 0
{Invocation Service - Shutdown} --<Fatal> -- 2014-02-27 15:56:21 -- Main Thread Error. Exception: 
System.IndexOutOfRangeException

Level 1) Index was outside the bounds of the array.

StackTrace for Level 1:
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.GetExpiredEvents()
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.HandleExpiredEvents(DeviceEntity& devAccess, ExecutionQueueAccess& execAccess, ScenarioEntity& scenarioAccess, ScenariosDevicesEntity& scenariosDevicesAccess, IList`1& retryStorage, Int32& genericSendCount, TimeSpan& genericStateLockPeriod)
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.PullAndExecuteEventStackV2(DeviceEntity& devAccess, DeviceTypeEntity& devTypeAccess, DeviceModeEntity& devModeAccess, DeviceActionEntity& devActionAccess, InvocationEngine& engine, ScenarioEntity& scenarioAccess, SystemStateEntity& stateAccess, ScenariosDevicesEntity& scenariosDevicesAccess, ScheduleEntity& calcAccess, ExecutionQueueAccess& execAccess, DataSourceEntity& dsAccess, DataSourceValueEntity& dsvAccess, RuleSetEvaluationAccess& evalAccess, EntityRuleSetEntity& ruleAccess)
   at SwitchKing.Server.WinSvcServiceHost.InvocationService.ProcessDeviceEvents()
{UnhandledExceptionController_Framework} --<Critical> -- 2014-02-27 15:56:22 -- Exception: 
System.IndexOutOfRangeException

Level 1) Index was outside the bounds of the array.

StackTrace for Level 1:
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.GetExpiredEvents()
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.HandleExpiredEvents(DeviceEntity& devAccess, ExecutionQueueAccess& execAccess, ScenarioEntity& scenarioAccess, ScenariosDevicesEntity& scenariosDevicesAccess, IList`1& retryStorage, Int32& genericSendCount, TimeSpan& genericStateLockPeriod)
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.PullAndExecuteEventStackV2(DeviceEntity& devAccess, DeviceTypeEntity& devTypeAccess, DeviceModeEntity& devModeAccess, DeviceActionEntity& devActionAccess, InvocationEngine& engine, ScenarioEntity& scenarioAccess, SystemStateEntity& stateAccess, ScenariosDevicesEntity& scenariosDevicesAccess, ScheduleEntity& calcAccess, ExecutionQueueAccess& execAccess, DataSourceEntity& dsAccess, DataSourceValueEntity& dsvAccess, RuleSetEvaluationAccess& evalAccess, EntityRuleSetEntity& ruleAccess)
   at SwitchKing.Server.WinSvcServiceHost.InvocationService.ProcessDeviceEvents()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
{UnhandledExceptionController_Framework} --<Critical> -- 2014-02-27 15:56:22 -- Exception: 
System.IndexOutOfRangeException

Level 1) Index was outside the bounds of the array.

StackTrace for Level 1:
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.GetExpiredEvents()
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.HandleExpiredEvents(DeviceEntity& devAccess, ExecutionQueueAccess& execAccess, ScenarioEntity& scenarioAccess, ScenariosDevicesEntity& scenariosDevicesAccess, IList`1& retryStorage, Int32& genericSendCount, TimeSpan& genericStateLockPeriod)
   at SwitchKing.Server.BusinessAccess.Invocation.EventQueueAccess.DeviceEventEntity.PullAndExecuteEventStackV2(DeviceEntity& devAccess, DeviceTypeEntity& devTypeAccess, DeviceModeEntity& devModeAccess, DeviceActionEntity& devActionAccess, InvocationEngine& engine, ScenarioEntity& scenarioAccess, SystemStateEntity& stateAccess, ScenariosDevicesEntity& scenariosDevicesAccess, ScheduleEntity& calcAccess, ExecutionQueueAccess& execAccess, DataSourceEntity& dsAccess, DataSourceValueEntity& dsvAccess, RuleSetEvaluationAccess& evalAccess, EntityRuleSetEntity& ruleAccess)
   at SwitchKing.Server.WinSvcServiceHost.InvocationService.ProcessDeviceEvents()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Do you have any idea what this might be?

Cheers!

Re: Main Thread Fatal Error

Posted: Mon 03 Mar 2014, 07:39
by cyberde
Anything?

Also, it happens quite often that SK stops processing the signals received by the telldus, you'll see the telldus blinking when pressing a switch but the datasource doesn't change in SK.
When I restart the framework service (which also restarts all other sercvices) SK becomes responsive again to telldus signals and everything works again as expected.

Re: Main Thread Fatal Error

Posted: Mon 03 Mar 2014, 20:34
by Martin
Your second problem - with Switch King stop receiving signals, should be solved by using Telldus 2.1.2 beta.

About your first problem - how are you usually running your system? Are you frequently using scenarios? Do you update or manipulate data through the REST interfaces or using any external applications or plugins?

From what I can recall, we have seen the error once or twice before but has never been able to reproduce it.

Re: Main Thread Fatal Error

Posted: Tue 04 Mar 2014, 09:16
by cyberde
Okay, I have installed 2.1.2beta10 :) But the SK client now says that the version isn't recognized and I should at least use 2.1.0... Guess it doesn't recognize the beta part ;)

I'm running the system using everything you say. But mostly I use it with systemmodes and REST data manipulation. I've written a SK plugin that catches datasource changes and telldus signals, forwards this to my domotica system service which then does specific actions, which can also contain updating other datasources in SK using REST.
A recent thing I've added is that sequential datasource updates (eg pressing the on button on a remote twice) send a sync signal to the device (REST/devices/id/synchronize) or a dim signal if enabled for that device. Could it be that I'm trying to sync devices too fast?

The only weird part is that it is pretty impossible to reproduce, I've had this error twice now, while doing the exact same thing as I've done before without any other results.

Re: Main Thread Fatal Error

Posted: Wed 05 Mar 2014, 20:58
by Martin
Hopefully, there will be a "real" 2.1.2 soon, but you can remove the error message by modifying Windows registry (if you know what you are doing).

On a 64 bit environment, the key is found under:
HKLM\Software\Wow6432Node\Telldus

...or on 32 bit environment:
HKLM\Software\Telldus

Look for the string " beta" and remove it.

Would it be possible to see any kind of pattern in terms of what happens just befor the exception? I am thinking that it might have to do with a specific event is being triggered, a specific device is in play etc.
Do you have more than one log file showing the error?

Re: Main Thread Fatal Error

Posted: Thu 06 Mar 2014, 14:43
by cyberde
I have removed the beta string and the message is indeed gone, now just wait for the "real" 2.1.2 :)

Yes I have multiple (two at the moment) logs available, I have attached these.
It seems to happen when I switch to a specific system mode, but irregularly.

Re: Main Thread Fatal Error

Posted: Fri 07 Mar 2014, 15:22
by Martin
Can you send me your DB in a PM or email? There is one particular warning that is of interest - "ScheduleMode with id 3 is bound to an nonexisting schedule."
Maybe this could be fixed with a script.

Re: Main Thread Fatal Error

Posted: Fri 07 Mar 2014, 16:31
by cyberde
Sent :)

Re: Main Thread Fatal Error

Posted: Sat 08 Mar 2014, 13:10
by Martin
Have attached a new version of the server (in a PM) which will not fix the root issue (due to that I haven't been able to track it down) but that should stop the server from crashing.

Re: Main Thread Fatal Error

Posted: Sat 08 Mar 2014, 14:55
by cyberde
Martin wrote:Have attached a new version of the server (in a PM) which will not fix the root issue (due to that I haven't been able to track it down) but that should stop the server from crashing.
Thanks, I have installed 3.2.4.1 and I'll keep you posted! :)