#1 2021-05-25 21:58:32

wxinix
Member
Registered: 2020-09-07
Posts: 121

TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'?

How would TSynLog work, if TSynLogPerThreadMode = ptIdentifiedInOnFile, and

I am scratching my head, because I am occasionally having EIOError with "File access denied" problem.  By "occasionally" - I meant - the application (mORMot2 based)  will run normally for a couple of hours then it crashes with "File access defined" error.

Any advice?  This might not be mORMot2 problem but I am asking just in case folks here may share some insights.

Offline

#2 2021-05-26 07:32:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'?

I guess the first sentence is not finished.

Enable the logs and see where exactly the EIOERror is triggered.
I doubt it comes from TSynLog.

Offline

#3 2021-05-26 20:41:23

wxinix
Member
Registered: 2020-09-07
Posts: 121

Re: TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'?

ab wrote:

I guess the first sentence is not finished.

Enable the logs and see where exactly the EIOERror is triggered.
I doubt it comes from TSynLog.

The whole story is here  https://en.delphipraxis.net/topic/5092- … violation/

Basically,  I had a multi-threaded application (mORMot2), which also uses TSynLog for logging purpose.  I have TSynLogPerThreadMode = ptIdentifiedInOnFile

Then,  the application after started, would run normal for a couple of hours, then it crashed.  By "a couple of hours" -  it is really random, sometimes it is 2~3 hours, sometimes more.

The crash is only logged by Windows Event Viewer, as Access Violation, with the fault offset.   TSynLog itself didn't log anything.  madExcept (if enabled) didn't log anything either.  FastMM5 (if enabled) didn't log anything, either.

From the fault offset, I can trace into somewhere in EIOError code.

If I turn off TSynLog completely,  then the access violation would be gone, and never happened.  Therefore, I suspect it is something related to TSynLog under multi-threaded environment. 

Right now, I had to turn of TSynLog and the application seems running all right without any problem.

Last edited by wxinix (2021-05-26 20:43:19)

Offline

#4 2021-05-27 07:14:19

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'?

TSynLog is use on production on heavily loaded servers since years.
One thing to know is that the log files are locked during process. They should not be opened directly during process.
If you have opened a log file during rotation, it may have troubles doing the renaming for the rotation.

Also what is the log context when it happens?

Offline

#5 2021-05-31 13:15:20

flydev
Member
From: France
Registered: 2020-11-27
Posts: 50
Website

Re: TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'?

Just in case, read @ab's and @mpv's comment there :  https://synopse.info/forum/viewtopic.php?id=5793

I have also more than 80 clients with servers in production  (on mormot v2 now) and no TSynLog issue since months. I can remember having issue with TSynLog but it was my learning curve that was not completed, and the issue was introduced by me, it was also a bit hard to spot as I am mixing mORMot2 and OmniThreadLibrary.

Offline

#6 2021-06-01 00:24:09

wxinix
Member
Registered: 2020-09-07
Posts: 121

Re: TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'?

Thank you @ab and @flydev

It turns out the problem was caused by a StackOverFlow exception when the software was trying to sort an array in a background thread (spawned by OmniThread Lib).  I used EurekaLog (with multi-threading enabled) to figure that out.  So it is not mORMot2 or TSynLog problem.

But I do have a question - it seems that TSynLog cannot capture the StackOverFlow exception that happened in a background thread?

Offline

#7 2021-06-01 06:58:16

flydev
Member
From: France
Registered: 2020-11-27
Posts: 50
Website

Re: TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'?

wxinix wrote:

But I do have a question - it seems that TSynLog cannot capture the StackOverFlow exception that happened in a background thread?

This might be due to OTL. Read this sentence about Exception notifications: http://www.omnithreadlibrary.com/book/chap14.html - then you can try to call your ILog.Log() mecanism inside your exception filter.

Offline

Board footer

Powered by FluxBB