Question

Has anyone run into a situation where a WaitAny call returns a valid handle index, but the Proxy.End call blocks? Or has any recommendations or how best to debug this - tried tracing, performance counters (to check the max percentages), logging everywhere

The test scenario: 2 async. requests are going out (there's a bit more to the full implementation), and the 1st Proxy.End call return successfully, but the subsequent blocks. I've check the WCF trace and don't see anything particularly interesting. NOTE that it is self querying an endpoint that exists in the same process as well as a remote machine (=2 async requests)

As far as I can see the call is going through on the service implementation side for both queries, but it just blocks on the subsequent end call. It seems to work with just a single call though, regardless of whether it is sending the request to a remote machine or to itself; so it something to do with the multiple queries or some other factor causing the lockup.

I've tried different "concurrencymode"s and "instancecontextmode"s but it doesn't seem to have any bearing on the result.

Here's a cut down version of the internal code for parsing the handle list:

ValidationResults IValidationService.EndValidate()
    {
        var results = new ValidationResults();

        if (_asyncResults.RemainingWaitHandles == null)
        {
            results.ReturnCode = AsyncResultEnum.NoMoreRequests;
            return results;                
        }

        var waitArray = _asyncResults.RemainingWaitHandles.ToArray();
        if (waitArray.GetLength(0) > 0)
        {
            int handleIndex = WaitHandle.WaitAny(waitArray, _defaultTimeOut);
            if (handleIndex == WaitHandle.WaitTimeout)
            {
                // Timeout on signal for all handles occurred                    
                // Close proxies and return...
            }

            var asyncResult = _asyncResults.Results[handleIndex];



            results.Results = asyncResult.Proxy.EndServerValidateGroups(asyncResult.AsyncResult);

            asyncResult.Proxy.Close();
            _asyncResults.Results.RemoveAt(handleIndex);
            _asyncResults.RemainingWaitHandles.RemoveAt(handleIndex);

    results.ReturnCode = AsyncResultEnum.Success;
            return results;
        }

    results.ReturnCode = AsyncResultEnum.NoMoreRequests;
        return results;
    }

and the code that calls this:

 validateResult = validationService.EndValidateSuppression();
 while (validateResult.ReturnCode == AsyncResultEnum.Success)
 {
       // Update progress step                        
       //duplexContextChannel.ValidateGroupCallback(progressInfo);

     validateResult = validationService.EndValidateSuppression();
 }

I've commented out the callbacks on the initiating node (FYI it's actually an 3-tier setup, but the problem is isolated to this 2nd tier calling the 3rd tier - the callbacks go from the 2nd tier to the 1st tier which have been removed in this test). Thoughts?

Was it helpful?

Solution

Sticking to the solution I left in my comment. Simply avoid chaining a callback to an aysnc calls that have different destinations (i.e. proxies)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top