mirror of
https://github.com/Pro/dkim-exchange.git
synced 2026-04-25 08:55:52 +03:00
[GH-ISSUE #112] Event 1057, MSExchange Extensibility - Agent 'Exchange DkimSigner' went async #88
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @luckman212 on GitHub (Nov 18, 2015).
Original GitHub issue: https://github.com/Pro/dkim-exchange/issues/112
Originally assigned to: @Pro on GitHub.
Since installing dkim-exchange on our Ex2013 server, I am getting many, many of these errors in the Event Log:
Event 1057, MSExchange Extensibility
Agent 'Exchange DkimSigner' went async but did not call Resume on the new thread, while handling event 'OnCategorizedMessage'
I found a related article on MSDN:
Agent went async but did not call Resume (Event Id 1057)
I don't know if this would be a fairly easy thing to fix.
@AlexLaroche commented on GitHub (Nov 19, 2015):
Which version of the agent is used ?
@Pro commented on GitHub (Nov 21, 2015):
We fixed this already in the current version (see #97).
If you are using the current version (2.1.8) and the problem stil persists, please reopen this thread.
@mrrogers75 commented on GitHub (Dec 17, 2015):
I am having this issue in 2.1.8
@Pro commented on GitHub (Dec 17, 2015):
@mrrogers75 what is your windows version? Exchange version (including SP and Updates)?
@mrrogers75 commented on GitHub (Dec 17, 2015):
Windows Server 2012 R2 with Exchange 2013 SP1 CU 10
On Dec 17, 2015 2:38 PM, "Stefan Profanter" notifications@github.com
wrote:
@gogglespisano commented on GitHub (Jan 1, 2016):
Shouldn't GetAgentAsyncContext() be called from the original thread, then Resume() called in the worker thread?
Wouldn't it be better to queue the processing on a ThreadPool thread rather than creating a new thread for every email message?
@Pro commented on GitHub (Jan 2, 2016):
@gogglespisano thanks for the info. Changed in
github.com/Pro/dkim-exchange@0e4f1c6b79@gogglespisano commented on GitHub (Jan 19, 2016):
I wonder if the agent is using the thread pool to process the message, and then the "new" thread is the same thread pool thread being used for the Resume call.
Or maybe the event message is trying to tell us something else and it's just a poor message.
@Pro commented on GitHub (Jan 19, 2016):
It looks like the problem still exists, as by @lukehamburg reported in bug #136.
According to the official Microsoft Sample code, the current way we handle AsyncContext should be fine...
http://www.getcodesamples.com/src/D062E1E9/2552BA7
The only difference I see is:
compared to the sample code
But this should be the same (see http://stackoverflow.com/a/15695940/869402)
@Pro commented on GitHub (Jan 19, 2016):
@gogglespisano this may be a valid point. So one way to test it would be to create our own Thread instead of using the ThreadPool.
As it was in
github.com/Pro/dkim-exchange@7eee8db425@gogglespisano commented on GitHub (Jan 19, 2016):
Is it possible this condition is not getting set correctly?
#if !EX_2007_SP3
@Pro commented on GitHub (Jan 19, 2016):
The only place where this define is set is at https://github.com/Pro/dkim-exchange/blob/master/Src/Exchange.DkimSigner/Exchange.DkimSigner.csproj#L36
So it should be correct, but I'll try to do some debugging to see if it is set correctly.
@Pro commented on GitHub (Jan 19, 2016):
#if !EX_2007_SP3is set correctly. I just checked it.So the .Resume call is definitely compiled.
@luckman212 commented on GitHub (Jan 19, 2016):
@gogglespisano asked in #136 before it was closed: "What is the ratio of the event messages to emails processed? is it 1:1 or something much different?".
I am not sure how to scientifically answer this, but we've sent a few hundred emails since the DkimSigner was installed around 2am EST this morning the event 1057 has only been logged 9 times.
@Pro commented on GitHub (Jan 19, 2016):
Thanks for the info. So this means that it is not logged for every mail.
Are there any error messages or other warnings in the DKIM signer log around that time when the 1057 Event is logged?
@Pro commented on GitHub (Jan 19, 2016):
@lukehamburg Can you enable Debug Logging and wait until the next 1057 event is logged and check the debug messages in the Event Log?
@gogglespisano commented on GitHub (Jan 19, 2016):
I wonder if the relatively small percentage of times it's happening could be reuse of the same thread pool thread.
@Pro commented on GitHub (Jan 19, 2016):
That could be the case since ThreadPool is shared for the whole process. The signer .dll is loaded into the EdgeTransport.exe process and thus it may be the case that exchange uses the same ThreadPool internally.
To investigate that further, a Debug output of
Thread.CurrentThread.ManagedThreadIdmay help.Or we could switch to use Task instead (https://msdn.microsoft.com/en-us/library/system.threading.tasks.task%28VS.100%29.aspx)
@gogglespisano commented on GitHub (Jan 19, 2016):
I would try to find out if the thread reuse is the actual problem before trying something like the Task.
@AlexLaroche commented on GitHub (Jan 20, 2016):
@Pro: Have you try something like that to solve the problem?
@Pro commented on GitHub (Jan 20, 2016):
@AlexLaroche the only change in your code is that you moved the agentAsyncContext outside of the try catch. Am I right?
I don't think that this changes anything.
What I'll try to do is to see if
Thread.CurrentThread.ManagedThreadIdcan be used to identify the thread within a ThreadPool and add some debug output to check if Exchange uses the same thread as the Signer.@AlexLaroche commented on GitHub (Jan 20, 2016):
@Pro : It is a best practice to call AsyncAgentContext.Resume() in your worker thread before doing any work to complete the event. This ensures that the thread is properly initialized for asynchronous event handling.
If you check à MSIL (Microsoft Intermediate Language) level you will see that the code generate is different. Is the try catch block is interpreted as instruction before AsyncAgentContext.Resume()? I know is sound crazy but we could give a try. It's just a suggestion.
@luckman212 commented on GitHub (Feb 27, 2016):
@Pro I installed 3.0.2 today. Still getting these in the Event Log. I was going to try to enable Debug Logging as you said, but not quite sure how to do that. Do I just set 5 in the settings.xml or something like that?
@Pro commented on GitHub (Feb 27, 2016):
Yes unfortunately I didn't find any fix for this log entry yet. I need to investigate that further. I think there might be some race condition.
Anyways this doesn't have any impact on the functionality of the DKIM signer.
@lukehamburg you can try to enable Debug (set 4 in settings.xml) and check if the Event Log is fired if two mails are send nearly at the same time. Maybe there is also some other correlation between the 1057 event and debug outputs of the signer.
@supermistag commented on GitHub (Nov 25, 2016):
Had the same issue in our Agent, spent a bit of time trying various locations for the .Resume() and eventually nailed it.
The documentation on the interweb kind of infers you should call .Resume before doing any work to COMPLETE the event. Not sure what else can be called other than Complete(), maybe a research for another day ...
Hope this helps. I see many other agents suffering the same problem.
@BrianDrab commented on GitHub (Jan 5, 2018):
We are encountering the same issue.
Exchange Version: 15.1.1261.35
DKIM Signer Version: 3.0.12
Windows Server Version 6.3 (Build 9600) aka Server 2012 R2
Is this an error we should just ignore?
@Pro commented on GitHub (Jan 14, 2018):
You can probably just ignore this message, since it doesn't impact the functionality of the signer
@supermistag commented on GitHub (Jan 15, 2018):
Ignoring an error in the event log becomes bad practice IMHO.
As per my above post, the fix in the code is fairly simple - moving the .resume to just before .complete
@BrianDrab commented on GitHub (Jan 15, 2018):
I saw that but can you tell me the file I can make this code change in or is it something a developer has to do?
@supermistag commented on GitHub (Jan 15, 2018):
A developer would need to make the change.
@Pro commented on GitHub (Feb 7, 2018):
Fixed in #208
@shumaid commented on GitHub (Mar 6, 2024):
Event 1057
Agent 'Exchange DkimSigner' went async but did not call Resume on the new thread, while handling event 'OnCategorizedMessage'
It is still happening on Windows 2012 R2 running Exchange 2016 CU23 15.1.2507.6 Signer 3.4.0
The DKIM is not working ! any idea what might be the problem?
Thanks