Bug #57473 MYD/MYI file locked after close
Submitted: 15 Oct 2010 7:11 Modified: 15 Oct 2010 8:05
Reporter: Olivier Olivier Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.2.2 OS:Any
Assigned to: CPU Architecture:Any

[15 Oct 2010 7:11] Olivier Olivier
Description:
Hi,

I noticed that Mysql files where still locked after conn.close. I noticed that doing a winrar, which reports that it can't access to files because they are in use.

I want to use winrar to save files in a rar archive.

Files are the one of tables that I loaded thru example below. "pooling=false" is set in the connection string.  

Thanks for any help.

Olivier

How to repeat:

    Structure S_table
        Dim data As DataTable
        Dim da As MySqlDataAdapter
        Dim cb As MySqlCommandBuilder
    End Structure

Dim table as S_table

With table
.data = New DataTable
.da = New MySqlDataAdapter(sql, cnx)
.cb = New MySqlCommandBuilder(.da)
.da.Fill(.data)
cnt = .data.Rows.Count    ' Nombre de résultats trouvés
End With
[15 Oct 2010 7:16] Tonci Grgin
Olivier, why do you think this is a MySQL problem, why is this c/NET problem and what are you trying to back up with RAR in the first place?
[15 Oct 2010 7:36] Olivier Olivier
Hi Tonci, thanks for your answer.

My problem is that I'm not able to locate from where this problem comes from. 

I'm trying to rar the MYD/MYI files (not Innodb) of my db folder. Of course, I can and will, stop mysql services which unlocks the file.

But it does'nt appear to me "normal" that after calling mysqlconnection.close, the accessed files are still locked by mysql.

I tried .data.dispose, .da.dispose but it does'nt change anything.
[15 Oct 2010 7:41] Valeriy Kravchuk
I think our manual, http://dev.mysql.com/doc/refman/5.1/en/table-cache.html, explains what happens.
[15 Oct 2010 7:45] Tonci Grgin
Olivier, the lock on files is exclusively held by MySQL server. So, in order for your idea to work, after closing .NET program you need to shut MySQL server down. I see no other way to keep data consistent but for server to have a lock on them.

If you think MySQL server should hold more relaxed type of lock over the database files, please file a server feature request.

Finally, there are handy utilities, like "Who locked me" which integrates into the Explorer shell, that might tell you the exact holder of a lock.

I see no bug here.
[15 Oct 2010 7:55] Olivier Olivier
Valeriy, I tried to find a flush command that I could call from vb and didn't find one. I you have an idea.

Tonci, could you confirm that if I stop mysql service after da.update it's an academic way of doing things and there is no risk to lose data ?
[15 Oct 2010 8:00] Tonci Grgin
No Olivier, it is not an "academic" way of doing things... The best way would be to leave the server running and issue mysqldump command from within your program. I am not here to review the code so I can't help more but surely you know of many ways on how to call "DOS" programs from .NET and pass them some parameters.

Again, this is not a bug and Valeriy and myself are no replacement for Google, manual etc.
[15 Oct 2010 8:05] Olivier Olivier
Ok, thanks for your kind help.