Durable function stuck in running state - azure-durable-functions

I have a durable function which get stuck in "Running" status when an activity function fails. No activity function is running, why would that be the case? Last update date for this instance in functionInstances table is 2020-11-19T05:00:32.761Z

I have found an excellent tool to use to debug and trace Durable func apps: https://github.com/microsoft/DurableFunctionsMonitor
It proved very difficult to see what's happening within the hub/control queues/instances and history tables - this tool helps a lot with visualizing that. I'm running it as a VS Code extension:)

Checked the logs in application insights and found that application is continuously throwing outofmemoryexception. Fixed that problem and now application is working fine.

Related

How to automate getting ZKTeco Access Control Logs

How can I automate getting the logs of ZKTeco access control devices (InBio160/260)? The documentation regarding the SDK is not understandable at all. From the GUI perspective, you select the devices, press Get logs, and select delete all logs after downloading them. This is something that is done constantly so I don't understand why there is not a built-in scheduler performing this task?
If anyone has set up a ZKTeco access control system or worked with their SDK, any help would be appreciated. Attached is the UI and the get logs button I want to automate.
I need to sync data between different buildings but if the logs are not downloaded to the SQL Server a few times a day, the syncing program will not function properly.
I wrote an SDK wrapper in C#. Code on github
It contains all functions you may need, It can at least help you understand the SDK.
This is the function you want to call to get the log: ReadTransactionLog
Transaction[]? transactions = ReadTransactionLog(0); // 0 = all log, epoch time in seconds

setInterval Stops After An Hour With Electron

Hoping someone can point me in the right direction here. My electron app needs to perform an API call every 10 minutes or so. I currently do this using a setInterval loop in the renderer process that fires every 10 minutes.
It generally works fine, for a few hours before it seems to just stop firing. I have several processes that clear and restart the setInterval to try and counteract the problem, but nothing seems to work.
The app opens new browser windows and displays content, which mean the main window may not be in focus all the time, which I suspect may have something to do with it.
I have tried adding
powerSaveBlocker.start("prevent-display-sleep");
powerSaveBlocker.start("prevent-app-suspension");
to my main electron js script, but it doesn't seem to have an effect. The problem is mostly being displayed on Windows machines. I'm not entirely sure if it happens on Mac or Linux.
So my question, is there any reason why this would be happening that intervals just die after a point? The powerSaveBlocker calls made sense to me, but they don't really seem to do anything.
Or is there a better way to have a background process running at intervals that can perform these API calls? I had looked at node-schedule but I'm not sure if it will fix this issue.
Answering my own question here with credit to #snwflk who pointed me in the right direction in a comment on the original post.
Whilst I have not been able to clarify with absolute certainty this solves the problem, I have also not seen the problem since. (It's not always 100% reproducible, and its difficult to test as it requires a machine, left alone for several hours, which may or may not display the problem).
I have however rolled the fix out to a few customers and their machines seem to still be online days later, which is a good sign.
So, the solution was to disable backgroundThrottling on the main BrowserWindow object (interval was running in the renderer processes)
Docs: https://electronjs.org/docs/api/browser-window#new-browserwindowoptions
An example
mainWindow = new BrowserWindow({
webPreferences: {
backgroundThrottling: false,
},
});
FYI be warned there have been a few bugs that prevented this setting from working, ie https://github.com/electron/electron/issues/20974 so be sure to update your electron version.
As far as I know intervals should keep running forever (the MDN page also doesn't mention anything).
If I understood correctly, your Electron app only does that API call? So it would be hard to tell the difference between the interval not triggering, and some other problem causing a freeze?
My guess would be you have an uncaught exception being thrown, or some other similar error or event. https://stackoverflow.com/a/43911292/841830 gives some suggestions of things to catch. https://github.com/sindresorhus/electron-unhandled says it can be used in both main and renderer processes to catch and report all problems.
Or is there a better way to have a background process running at intervals that can perform these API calls?
If you were on Linux, using cron to run a node script (or even just a wget or curl command) would be better than using an Electron app just for this. Task scheduler seems to be the windows equivalent of cron.

Recurrent exception in Delphi TService on W10 and Server 2012r2

I am working on a Delphi application using the TService functionalities.
It is a large project that was started by someone else.
The application uses several separate threads for processing, communicating with clients, database access, etc. The application’s main job is to poll regularly (every 2-300ms) certain devices and, a couple times a day, execute specific actions.
Now somewhere there is an unhandled exception for which I cannot seem to find the cause:
According to the debugger, the faulting method is System.Classes.StdWndProc.
This also seems to be confirmed by analyzing the crash dump file with WinDbg.
After numerous tests and debugging, I noticed that the crash happened on my dev computer every day at almost the same time.
I looked at the windows log and found this event:
This, coupled with the fact that the stack trace from Delphi indicates that a message with ID=26 (WM_WININICHANGE) was processed, made me believe that there might be something wrong with my usage of FormatDateTime() or DateTimeToStr() when regional settings are reloaded.
I checked every call and made sure to be using the thread-safe overload with a local instance of TFormatSettings.
However today the service crashed again.
A few points that I think are worth mentioning:
The application is also installed on a Windows 2008 server and has
been running OK for over a month.
On 2012r2 I tried forcing DEP off, but it didn’t change anything.
The service’s OnExecute() method is not implemented. I create a base thread in TService. ServiceStart() which then in turn creates the main data module and all the other threads.
The service is not marked as interactive and is executed with the Local System account.
All data modules are created with AOwner=nil.
With a special parameter, the application can be started a normal windowed application with a main form (which is created only in this case). The exception does not seem to happen when running in GUI mode.
Almost all threads have a message pump and use PostThreadMessage() to exchange information. There are no window handle allocations anywhere.
I have checked the whole project and there are no timers or message dialogs or other graphical components anywhere.
I have activated range as well as overflow checking and found no issues.
I am a loss for what to do here. I have checked and re-checked the code several times without finding anything that could explain the error.
Looking online I found several reports that seem to be pertinent to my situation, but none that actually explains what is going on:
https://answers.microsoft.com/en-us/windows/forum/windows_10-other_settings/windows-10-group-policy-application-hang/72016ea4-ba89-4770-b1de-6ddf14b0a51f
https://www.experts-exchange.com/questions/20720591/Prevent-regional-settings-from-changing-inside-a-TService-class.html
https://forums.embarcadero.com/thread.jspa?messageID=832265
Before taking everything apart I would like to know if anyone experienced anything similar or has any tips.
Thanks
Edit: looking at the call stack and the first method executed I am thinking of the TApplication instance that is used in TService.
LPARAM is always 648680.
LPARAM is a pointer to a string (you can cast it to PChar).
You could try to catch WM_SETTINGS_CHANGE and log anytime it's processing.
I think you could use TApplicationEvents component. The component has OnSettingsChange event. The event provides a setting area name (section name) and a flag that points to changed parameter.
Have a look at doc-wiki.
There is a full list of possible parameters.
I did not test it, but maybe you can use Abort procedure in OnSettingsChange event handler to stop the message distribution. Of course it's not a solution, but it may work.

SQLite.net exception on screen rotation on android 4.1+

I am currently working on a cross-platform application using Monodroid/Xamarin. It uses a SQLite.net database and at the moment I have only built the Android UI.
In the application there is a long running method on a background thread which does several database reads and writes.
I was testing this long running method on a Nexus 7 running android 4.2.2 and it seems as though after a second screen rotation, a SQLite exception is thrown and the application crashes.
The exception stack trace varies depending on when you rotate the screen but the exception is always object not set to an instance inside Prepare2.
The interesting part is when testing on Samsung Galaxy S2 running 4.1.2 an exception still occurs but it is a different exception.
Furthermore, testing on a Samsung Galaxy Tab 2 and emulators the error is not thrown at all and the method completes just fine.
Any ideas, hints, suggestions would be much appreciated.
As a side question - in all the cross platform applications i have seen using Xamarin - the database layer and or repository is always static - whats the reason for this?
Thanks everyone
It's hard to identify the problem from what you've written - would be easier if you'd included some code about how you are accessing the database from your app.
However, I suspect that the problem here will be due to some interaction between the lifecycle of your UI Activity and the way it interacts with the SQLite database.
By default, when you rotate an Activity, then the existing instance is destroyed and a new one is created - your old Activity will be called to store its state in SaveInstanceState and your new rotated Activity will get called with a bundle in OnCreate.
This is why the database layer is often static/singleton in the samples - it's an easy way to allow the same database instance to be shared by multiple Activities/Components.
I guess that your Activity is doing something with the database during OnCreate - and that this is being called after each rotation/creation? Alternatively maybe your long-running method is trying to do something after the Activity that's hosting it has been finished and disposed?
In the end, this turned out to be a issue with mulithreading and Linq not playing well together. Thanks to Stuart for his answer.

Mochiweb mnesia requests

I'm trying to link Mochiweb with my ejabberd mnesia db and am unable to do any mnesia transactions in my controllers. I test my controllers without the mnesia transactions and they work fine. I am using application:start(mnesia) inside the start function.
On the browser, I see "Internal server error" and on Mochiweb's log I see, "=ERROR REPORT=== function_clause". I'd like to know how to either 1.) get mnesia to work with Mochiweb or 2.) what a good framework I could plugin to ejabberd's web server is.
Thanks!
Do you have the rest of the error message from Mochiweb's log - the bit after "function_clause" if it has it?
This must be an error within your code. Last time I checked the mochiweb source it wrapped your "loop" function within a try catch. If it caught an exception, it printed the type of that exception to the error log; in your case you have a function_clause exception.
Either try calling your loop function manually, or wrap your code in yet another try catch to be able to see the whole exception. If you can't decipher it, paste it to your question please.
You know, I think I was doing it all wrong... I was thinking it would work like PHP/SQL and Rails/SQL, but it seems the best way to do this is calling methods from the Mochiweb node to the ejabberd node.
Also I noticed that when I started Mochiweb connected to the same mnesia database as ejabberd, it tried to "repair" some of my tables - basically erasing everything.
If anyone has any input on this (or if I'm totally off) please let me know. Thanks!

Resources