By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,119 Members | 2,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,119 IT Pros & Developers. It's quick & easy.

Thead in a Windows Service stuck waiting for LPC Reply

P: n/a
This is a tough one...

My Windows Service app periodically performs some processing on new entries
to a SQL Server database table. It uses a simple System.Timer to call the
Elapsed event handler (which contains the processing code) every minute. The
processing itself usually takes no more than a few seconds. Even so, I have
a boolean set in the event handler when I'm currently processing information
so that only one thread is permitted to run the actual processing code; that
way if a second timer event (on a second thread) is started before the first
is finished, the second thread bypasses the processing code entirely.

The problem arises intermittently: The service stops processing new items
in the database table, even though it is still running and reports no
exceptions. If the service is restarted, the stalled items in the database
are processed normally and items added later are also handled correctly.
Eventually the problem will show up again, however.

Due to intensive debugging, the code is now covered with logging statements
to assist with locating the source of the problem. A review of the log files
during the time the service seems stalled indicates that the worker thread
has made its way into a fairly unremarkable section of code and then refuses
to budge any further. A second thread then begins approximately 59 seconds
later, adding log entries that indicate it (correctly) bypasses the
processing code.

The last log entry for the stuck thread is from a different spot in the code
every time, but seems to occur in code similar to the following that does
nothing more than check that an object's value is not null and assign its
value to another object.

public static void MyProcessing(MyAObject a, MyBObject b)
Log("Entering MyProcessing...");
if (b.Property1 != null)
a.PropertyA = b.Property1;
Log("Leaving MyProcessing...");

The log contains a "Entering MyProcessing..." entry, but not a "Leaving
MyProcessing..." entry.

If I look at the threads in the System Monitor when the service seems
stalled, I see the following values

Counter Bypassing Thread Stuck Thread
ThreadID 6008 5368
Priority Base 8 8
Priority Current 9 8
Thread State 5 5
Thread Wait Reason 6 17

From this, it is apparent that the stuck thread is actually in a Waiting
state, and the reason is that it's waiting for an LPC Reply. But it is not
in a section of code that contains any calls to any local procedures.

What could be causing this thread to enter the waiting state in the first
place and is there a way to fix this problem?

Additional info: I'm running my .NET 2.0 on Windows Server 2003, Enterprise
Edition, with Service Pack 1.

Thanks for your help,


Oct 10 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.