Bug #62058 Unhandled exception from Mysql causes .Net Applications to terminate abruptly.
Submitted: 2 Aug 2011 11:30 Modified: 9 Aug 2011 10:36
Reporter: surender m Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.0.7 OS:Windows (2003 server)
Assigned to: Julio Casal CPU Architecture:Any
Tags: .Net application crash, Unhandled exception from Mysql

[2 Aug 2011 11:30] surender m
Description:
Dear All,

In our production server we have recently implemented password policy so that mysql user & password for .Net applications is been changed. Earlier it was running with root user with all permissions.

Now, we are facing a problem like whenever we are running mysql dump backup which uses mysql user[backupuser] then All the applications running on this production server were getting terminated abruptly with unhandled exception and we can see error for all the applications in event viewer with below details.

Source: .Net Runtime 2.0 Error EventID:5000 EventType clr20r3,P1 abc.exe,P2 1.0.0.0,P3 .., P4 mysql.data P5 5.0.7.0,P6 464b5d79,P7 21c,P8 76,P9 mysql.data.mysqlclient.mysql, P10 NIL.

But to our surprise, whenever we give super priviliges to mysql user for .net applications it is working fine i.e applications were not closing. 

Please suggest us a way to resolve this permissions issue.

For reference we have traced the unhandled exception while calling stored procedure from application:

Unhandled Exception: MySql.Data.MySqlClient.MySqlException: You are not

owner of thread 513814

 

 

Thanks in advance.

How to repeat:
step 1:  Running mysql dump backup for a database.
step 2:  Start .Net applications with limited priviliges.
[2 Aug 2011 12:28] Valeriy Kravchuk
Do you use KILL command in your application?
[2 Aug 2011 12:32] surender m
Thanks for the reply

No we are not using any KILL statement in applications.

We just connect to mysql and run sum sort of stored procedures which updates status in tables.
[3 Aug 2011 10:24] surender m
I have simulated this on my development server and got the same exception.

And then i tried changing the definer for stored procedures as mysql user for .net application then i got handled exception[Timeout period elapsed before getting the response].

So, Can i conclude that definer should be same as calling application for stored procedures?
[4 Aug 2011 17:13] Julio Casal
We need more information in order to reproduce this issue:

1. What is the relationship between the user you use for backups and the user you use to connect to MySQL in your .Net apps?
2. What kind of .Net apps do you have? Web Apps? WinForms Apps? Win Services?
3. Do your apps get terminated exactly when you start the backup process?
4. Do you have more info in your EvenViewer like a complete stacktrace?
5. What exact privileges does the user your apps use to connect to MySQL have?
6. Is the backup performed for the same database that your .Net apps connect to?
[5 Aug 2011 10:00] surender m
Thank you very much Julio Casal for the valuable feedback.

please find my answers below.

1. What is the relationship between the user you use for backups and the user you use to connect to MySQL in your .Net apps?
-ANS:  Both are different Users there is no relation b/w them.

2. What kind of .Net apps do you have? Web Apps? WinForms Apps? Win Services?
-ANS:  Console Applications

3. Do your apps get terminated exactly when you start the backup process?
-ANS:  Yes, Whenever we start our backup process then applications get terminate in 30 - 40 secs[approx].

4. Do you have more info in your EvenViewer like a complete stacktrace?
-ANS:
Event Type:	Error
Event Source:	.NET Runtime 2.0 Error Reporting
Event Category:	None
Event ID:	5000
Date:		7/17/2011
Time:		2:05:20 AM
User:		N/A
Computer:	TEST
Description:
EventType clr20r3, P1 test.exe, P2 1.0.0.0, P3 4a7bf194, P4 mysql.data, P5 5.0.7.0, P6 464b5d79, P7 21c, P8 76, P9 mysql.data.mysqlclient.mysql, P10 NIL.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 63 00 6c 00 72 00 32 00   c.l.r.2.
0008: 30 00 72 00 33 00 2c 00   0.r.3.,.
0030: 74 00 69 00 6f 00 6e 00   t.e.s.t.
0038: 2e 00 65 00 78 00 65 00   ..e.x.e.
0040: 2c 00 20 00 31 00 2e 00   ,. .1...
0048: 30 00 2e 00 30 00 2e 00   0...0...
0050: 30 00 2c 00 20 00 34 00   0.,. .4.
0058: 61 00 37 00 62 00 66 00   a.7.b.f.
0060: 31 00 39 00 34 00 2c 00   1.9.4.,.
0068: 20 00 6d 00 79 00 73 00    .m.y.s.
0070: 71 00 6c 00 2e 00 64 00   q.l...d.
0078: 61 00 74 00 61 00 2c 00   a.t.a.,.
0080: 20 00 35 00 2e 00 30 00    .5...0.
0088: 2e 00 37 00 2e 00 30 00   ..7...0.
0090: 2c 00 20 00 34 00 36 00   ,. .4.6.
0098: 34 00 62 00 35 00 64 00   4.b.5.d.
00a0: 37 00 39 00 2c 00 20 00   7.9.,. .
00a8: 32 00 31 00 63 00 2c 00   2.1.c.,.
00b0: 20 00 37 00 36 00 2c 00    .7.6.,.
00b8: 20 00 6d 00 79 00 73 00    .m.y.s.
00c0: 71 00 6c 00 2e 00 64 00   q.l...d.
00c8: 61 00 74 00 61 00 2e 00   a.t.a...
00d0: 6d 00 79 00 73 00 71 00   m.y.s.q.
00d8: 6c 00 63 00 6c 00 69 00   l.c.l.i.
00e0: 65 00 6e 00 74 00 2e 00   e.n.t...
00e8: 6d 00 79 00 73 00 71 00   m.y.s.q.
00f0: 6c 00 20 00 4e 00 49 00   l. .N.I.
00f8: 4c 00 0d 00 0a 00         L.....  

5. What exact privileges does the user your apps use to connect to MySQL have?
-ANS: all the privileges except shut_down_db,super_prev,alter_routine_prev

6. Is the backup performed for the same database that your .Net apps connect to?
-ANS: Yes.
[5 Aug 2011 16:03] Julio Casal
Thanks for the additional info. I can see that you are using C/Net 5.0.7, which is not a supported version today. Can you please upgrade to our latest available version and let us know if you see any change on you applications behavior?
[8 Aug 2011 4:50] surender m
Thanks Julio..

I have updated latest connector now its getting handled exception, applications are working fine.

But when i upgrade c/net to 6.4.3 then i am getting "out of sync with server" error. Then i degraded c/net to 6.3.7 then its working fine.

One more thing can i upgrade connectors reference dynamically? 

In our applications we were adding reference to mysql connector[mysql.data] with some version and making it onto live server. now if i face any problem with connector then i have to update reference to newer version by recompiling code.

Is there a way to update reference without recompiling the code?

Thanks once again.
[8 Aug 2011 12:57] Julio Casal
Surender, the issue you are having with 6.4.3 has already been reporte and is being investigated (Bug #61806). Please use C/Net 6.3.7 in the meanwhile.

Yes, you can update references without recompiling code. Please check this MSDN page for more information: http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx
[9 Aug 2011 10:36] surender m
Thank You very much Julio Casal ..

God bless you..