Bug #114065 "One or more errors occurred." may occur when opening MySqlConnection.
Submitted: 20 Feb 2024 13:00 Modified: 28 Mar 2024 13:44
Reporter: Ryousuke Tanida Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.3.0 OS:Windows
Assigned to: CPU Architecture:Any

[20 Feb 2024 13:00] Ryousuke Tanida
Description:
MySqlConnection's "OpenAsync" is executed using the source code below.
---------------------------------------------------------------------
try
{
	var connectionString="Server=localhost;Database=databaseaname;Uid=username;Pwd=password;Host=127.0.1;Pooling=True;Connection Lifetime=10;ConnectionTimeout=2;CharSet='utf8mb4'"
	var lc = new MySqlConnection(connectionString);
	await lc.OpenAsync().ConfigureAwait(false);
}
catch (Exception me)
{
	//Error log processing
}

---------------------------------------------------------------------

In most cases there is no error, but it crashes in ExecuteCallbackHandlers of System.Threading.CancellationTokenSource.
The error details are as follows. 
---------------------------------------------------------------------------------
System.AggregateException
  HResult=0x80131500
  Message=One or more errors occurred. (Authentication to host '127.0.1' failed. (I/O error occurred.))
  Source=System.Private.CoreLib
  Stack trace:
   place System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException) (System.Threading\CancellationTokenSource.cs):line 660
   place System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool) (System.Threading\TimerQueueTimer.cs):line 259
   place System.Threading.TimerQueue.FireNextTimers() (System.Threading\TimerQueue.cs):line 218
   place System.Threading.ThreadPoolWorkQueue.Dispatch() (System.Threading\ThreadPoolWorkQueue.cs):line 690
   place System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() (System.Threading\PortableThreadPool.cs):line 1328

Inner exception 1:
AggregateException: Authentication to host '127.0.1' failed. (I/O error occurred.)

Inner exception 2:
IOException: I/O error occurred.

---------------------------------------------------------------------------------

From the error content, you can see that the error is due to MySql connection.
I use trycatch for OpenAsync, but it doesn't make sense.
This error did not occur when the version of MySql.Data was "8.0.32.1" and when running on .NetFramework.

Why does such an error occur?
If there is a problem, please correct it.
If there is no problem, could you please explain the reason for the error and how to deal with it?

How to repeat:
You can reproduce the problem by running the source code provided.
[20 Feb 2024 13:37] MySQL Verification Team
Hi Mr. Tanida,

Thank you for your bug report.

However, you have set your category to C API. Your code shows that this can not be C API. This is either Connector/J or Connector/C++.

Before we can continue any further work, we need you to be provide more precise info. Also, are server and connector that you are using both from 8.3.0 ........

Waiting on your feedback.
[20 Feb 2024 14:05] Ryousuke Tanida
Thank you for your reply

>However, you have set your category to C API. Your code shows that this can not be C API. This is either Connector/J or Connector/C++.
The code language used is C#.

>Before we can continue any further work, we need you to be provide more precise info. Also, are server and connector that you are using both from 8.3.0 .......
Is the server version the MySql version on Windows?
The result of the command "select version();" is "8.0.18".
Do I need to upload this version?

Waiting on your feedback.
[20 Feb 2024 14:21] MySQL Verification Team
Hi,

You wrote that you are using C/C*, while you set the category to C/J.

Hence, please fix that dilemma first.

Next, we need the versions of both, your C/C* and the version of MySQL Server. 

Do note that 8.0.18 is a deprecated release, hence use either 8.0.36 or 8.3.0 for BOTH , your Connector release and your server release.

We test only 8.0.36 releases of our Server and of our Connectors.

Hence, if we can not repeat the behaviour with either of the two, 8.0.36 and 8.3.0, we shall close this report.

I hope that you understand that you understood all the feedback that we need from you.
[26 Feb 2024 17:33] Ryousuke Tanida
Thank you for your reply.

First of all, I changed the category.

I changed the server version to 8.3.0 and verified it.
However, the problem was not resolved and there was no change in behavior.

Waiting on your feedback.
[26 Feb 2024 19:45] Ryousuke Tanida
additional information.
1. Even if the server is 8.3.0, it will not crash if the connection is 8.0.32.1.
2. It may also crash with the error below.
-------------------------------------------------- -------------------------------------------------- -----------------------
System.Collections.Generic.KeyNotFoundException
  HResult=0x80131577
  Message=The given key 'server=127.0.1;database=imusedb;user id=id;password=pass;pooling=True;connectionlifetime=10;connectiontimeout=2;characterset=utf8mb4' was not present in the dictionary.
  Source=System.Private.CoreLib
  Stack Trace:
   place System.ThrowHelper.ThrowKeyNotFoundException[T](T key)
   place System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   place MySql.Data.MySqlClient.MySqlPoolManager.<>c.<CleanIdleConnections>b__30_0(String key)
   place System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   place MySql.Data.MySqlClient.MySqlPoolManager.<CleanIdleConnections>d__30.MoveNext()
   place System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   place System.Threading.QueueUserWorkItemCallback.Execute()
   place System.Threading.ThreadPoolWorkQueue.Dispatch()
   place System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

-------------------------------------------------- -------------------------------------------------- -----------------------
We hope for your reference.
[27 Feb 2024 13:18] MySQL Verification Team
Hello Ryousuke,

Thank you for the bug report.
I tried to reproduce your issue on windows 11 with MySQL Server 8.3 using the code given but I am not seeing any issues at my end. 
Please check whether the host '127.0.1' is correct. Is it 127.0.0.1?

Also, please see Bug #110789. Thanks.

Regards,
Ashwini Patil
[27 Feb 2024 15:00] Ryousuke Tanida
Thank you for your reply.

>Please check whether the host '127.0.1' is correct. Is it 127.0.0.1?
We have confirmed that the local loopback address of the PC running the MySql server is '127.0.1'.
Although it may not be particularly relevant, the MySql server and connection are running on the same PC.

>Also, please see Bug #110789. Thanks.
There are only two points that can be gleaned from this bug report:
1.If OpenAsync throws a timeout exception, it will be thrown from the background thread pool thread.
As a result, the application cannot handle the exception and the entire process crashes.
2.MySQL Verification Team was able to confirm the content of the bug.

Has the above bug been fixed?
The content is the same as the bug I am reporting, but what should I refer to?

Waiting on your feedback.
[3 Mar 2024 7:26] Ryousuke Tanida
I hope this email finds you well. I wanted to follow up regarding the email I sent on February 27th. As I haven't received a response yet, I wanted to kindly remind you of the matter and inquire if you had the chance to review my previous email.

If you have any questions or need further clarification on the topics discussed, please don't hesitate to reach out. Your prompt attention to this matter would be greatly appreciated.

Thank you for your time and attention.

Best regards,
[4 Mar 2024 9:49] MySQL Verification Team
Hello Ryousuke,

Has the above bug been fixed?
Not yet. 
The content is the same as the bug I am reporting, but what should I refer to?
It means that this bug is duplicate of Bug #110789. 

Kindly wait for development team to fix the bug. Thanks.

Regards,
Ashwini Patil
[4 Mar 2024 14:10] Ryousuke Tanida
Thank you for your response.

#110789 was reported last April.
Why has this critical issue of hanging up on startup been left unaddressed for 11 months?
When will the issue be fixed?
Furthermore, as long as this issue persists, we cannot use MySql.
Please advise on a workaround for this issue.

Waiting on your feedback.
[9 Mar 2024 18:16] Ryousuke Tanida
I hope this email finds you well. I'm writing to follow up on our previous communication regarding topic. It's been some time since our last exchange, and we're eagerly awaiting your response.

Could you please provide an update or address the outstanding matters at your earliest convenience? Your prompt attention to this matter would be greatly appreciated, as it is crucial for us to proceed with task.

Thank you in advance for your cooperation, and I look forward to hearing from you soon.

Best regards,
[11 Mar 2024 1:28] Bradley Grainger
> This error did not occur when the version of MySql.Data was "8.0.32.1" and when running on .NetFramework.

This is because OpenAsync was implemented synchronously prior to MySql.Data v8.0.33; see bug #70111.

The new asynchronous implementation in v8.0.33 and later has some bugs that are yet to be worked out, e.g., see bug #110790, bug #110791 and of course bug #110789.

I would personally recommend switching to https://www.nuget.org/packages/MySqlConnector/ which has had a working asynchronous implementation for many years.
[28 Mar 2024 13:44] Ryousuke Tanida
Hello Bradley Grainger.
Sorry for the late reply.
I was able to fix it successfully using the library you suggested.
I give deep thanks at your favor.
[27 Nov 2024 16:19] MySQL Verification Team
This bug report is the original bug for this duplicate bug report:

https://bugs.mysql.com/bug.php?id=116757
[27 Nov 2024 16:26] ahmed taha
I reported this bug last year, and it exhibits the same issue: https://bugs.mysql.com/bug.php?id=113501