I (not me, J Jorgenson via stackoverflow.com) found the following will ensure integrity of MyISAM tables for any file-level manipulation:
LOCK TABLE x WRITE;
FLUSH TABLE x; -- closes all file handles into table by mysql.
Now you can perform file-level manipulations.
FLUSH TABLE x; -- A 'stat' of the table occurs and info-schema is updated appropriately.
UNLOCK TABLES;
If you do NOT lock-write your table, mysql may access it (reads or writes) while you are doing your file-level copy/manipulation. This is also the same mechanism used to allow 'myisampack', 'myisamchk' for tables on an HOT database that even has external locking disabled, without worries of corruption.
No comments:
Post a Comment