Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

product.Dispose() callbackTask.Wait() error #104

Open
simbahoo opened this issue Dec 26, 2016 · 9 comments
Open

product.Dispose() callbackTask.Wait() error #104

simbahoo opened this issue Dec 26, 2016 · 9 comments

Comments

@simbahoo
Copy link

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();
        }
    }
@treziac
Copy link
Contributor

treziac commented Dec 27, 2016

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)

@simbahoo
Copy link
Author

simbahoo commented Dec 28, 2016

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

@YosefFixler
Copy link

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.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()

@edenhill
Copy link

edenhill commented Feb 6, 2017

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

@ah-
Copy link
Owner

ah- commented Feb 6, 2017

Is this maybe one of the callbacks throwing an exception?

@YosefFixler
Copy link

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
Copy link

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

@YosefFixler
Copy link

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

@thebitllc
Copy link

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants