rdkafka-dotnet
rdkafka-dotnet copied to clipboard
product.Dispose() callbackTask.Wait() error
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();
}
}
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)
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
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 Are you seeing any (other) console output? E.g., an assert or similar
Is this maybe one of the callbacks throwing an exception?
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.
Debugging the code I find that the ThreadAbortException exception is thrown regardless to the consumer disposing. It happens before inside RdKafkaLib StartCallbackTask.
Hi Guys is there any news about this issue? My tests are stuck at BuildServer.
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();