rdkafka-dotnet icon indicating copy to clipboard operation
rdkafka-dotnet copied to clipboard

product.Dispose() callbackTask.Wait() error

Open simbahoo opened this issue 8 years ago • 9 comments

product.Dispose() An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll

protected virtual void Dispose(bool disposing) { callbackCts.Cancel(); callbackTask.Wait();//error:An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll

        if (disposing)
        {
            // Wait until all outstanding sends have completed
            while (OutQueueLength > 0)
            {
                handle.Poll((IntPtr) 1000);
            }

            handle.Dispose();
        }
    }

simbahoo avatar Dec 26 '16 10:12 simbahoo

Hi,

What is the InnerException and when does it occurs (when closing your app with alive broker, after a deconnexion...)? Which version do you use (latest prerelease solve many bugs)

treziac avatar Dec 27 '16 09:12 treziac

cannot see the detail error,only show this: callbackTask.Wait();//error:An unhandled exception of type 'System.AggregateException' occurred in , the versin is 0.9.2,I git clone from the git yestoday use the unittest, rdkafka.dll produce all write. but when close the unitmethod ,show this error

simbahoo avatar Dec 28 '16 13:12 simbahoo

The InnerException is ThreadAbortException. StuckTrace: at RdKafka.Internal.LibRdKafka.NativeMethods.rd_kafka_poll(IntPtr rk, IntPtr timeout_ms) at RdKafka.Internal.LibRdKafka.poll(IntPtr rk, IntPtr timeout_ms) in C:\rdkafka-dotnet-master\src\RdKafka\Internal\LibRdKafka.cs:line 285 at RdKafka.Internal.SafeKafkaHandle.Poll(IntPtr timeoutMs) in C:\rdkafka-dotnet-master\src\RdKafka\Internal\SafeKafkaHandle.cs:line 95 at RdKafka.Handle.<>c__DisplayClass27_0.<StartCallbackTask>b__0() in C:\rdkafka-dotnet-master\src\RdKafka\Handle.cs:line 161 at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.Execute()

YosefFixler avatar Feb 06 '17 20:02 YosefFixler

@YosefFixler Are you seeing any (other) console output? E.g., an assert or similar

edenhill avatar Feb 06 '17 20:02 edenhill

Is this maybe one of the callbacks throwing an exception?

ah- avatar Feb 06 '17 20:02 ah-

I forgot the aggregate exception stack trace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at RdKafka.Handle.Dispose(Boolean disposing) in C:\rdkafka-dotnet-master\src\RdKafka\Handle.cs:line 81 at RdKafka.Handle.Finalize() in C:\rdkafka-dotnet-master\src\RdKafka\Handle.cs:line 25

What I saw is the exception occurs at RdKafkaLib rd_kafka_poll() when the cancellation token is cancelled. Although the While condition checks if cancellation is required, the exception is thrown during the inner code execution.

YosefFixler avatar Feb 06 '17 21:02 YosefFixler

Debugging the code I find that the ThreadAbortException exception is thrown regardless to the consumer disposing. It happens before inside RdKafkaLib StartCallbackTask.

YosefFixler avatar Feb 07 '17 08:02 YosefFixler

Hi Guys is there any news about this issue? My tests are stuck at BuildServer.

YosefFixler avatar Mar 09 '17 11:03 YosefFixler

Any updates? We got the same issue. I believe the problem is due to callbackTask is in FAULT state and wait() throws an exception, the following fixes the problem.

            if (!callbackTask.IsCanceled && !callbackTask.IsFaulted)
                callbackTask.Wait();

thebitllc avatar Mar 28 '17 17:03 thebitllc