Current location: Hot Scripts Forums » Programming Languages » PHP » Where are MySQL cache files?


Where are MySQL cache files?

Reply
  #1 (permalink)  
Old 06-18-04, 04:05 AM
darkfreak's Avatar
darkfreak darkfreak is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Kuopio, Finland, Europe
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Where are MySQL cache files?

Hi!

My problem is the following:

At my work I use MySQL version 3.23 to store information of botanical specimen. Yesterday there happened a little disaster and we lost the data of approximately 1700 specimen because of the following.

I ran the flush-command in a different database (same server) during the development-process of another database which I am mainly working on. Everything else went fine but the Plants database didn't worked after that anymore and instead MySQL complained about corrupted table. I learned that this table in the Plants database was changed some time ago, when two new fields were added to it. If I have understood right, the changer didn't commit the flush-command neither before nor after changing the table. My guess is that some cache file got confused/corrupted at this point including data for both the old and new, changed table.

What is strange is that the database didn't show any signs of malfunction before that flush-command and it appeared that data was indeed added to the actual database. Also, in addition to data, also the two columns were missing from the table. After adding these back, the system worked fine but all the data typed in after the original table change is missing.

Everything (under the "/" in Linux server) is backed up on tape and theoretically I should be able to recover to the exact state of two days before the flush-command. In practice, however, this isn't the case, and even my personal backups that are more than 3 weeks old include the same corrupted MYD-file of that database (the size is something like 10k while it should be more than 1M).

I guess there isn't too much to do about the problem. However, I would like to know IF THERE ARE SOME OTHER FILES THAT MYSQL USES FOR SAVING/CACHING IN ADDITION TO MYI, FRM AND MYD FILES? If I would be able to restore these from the tape, could there be a slight chance of recovery of the system to the state before the flush-command? I have searched the system tmp-directory and database directories from the backup but I haven't found anything useful yet.

Please tell me if you have had any similiar problems and have recovered from them. Or if you think you have any information that could help me. Or if you know any other files MySQL uses for caching. Please DON'T tell me to upgrade to MySQL 4.x because after this it is already on our high-priority list

Thanks in advance and sorry if my english isn't perfect,

Yours,

darkfreak

Last edited by darkfreak; 06-18-04 at 04:10 AM.
Reply With Quote
  #2 (permalink)  
Old 06-18-04, 04:55 AM
Worm's Avatar
Worm Worm is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Germany, Frankfurt am Main
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by darkfreak
Hi!

My problem is the following:

At my work I use MySQL version 3.23 to store information of botanical specimen. Yesterday there happened a little disaster and we lost the data of approximately 1700 specimen because of the following.

I ran the flush-command in a different database (same server) during the development-process of another database which I am mainly working on. Everything else went fine but the Plants database didn't worked after that anymore and instead MySQL complained about corrupted table. I learned that this table in the Plants database was changed some time ago, when two new fields were added to it. If I have understood right, the changer didn't commit the flush-command neither before nor after changing the table. My guess is that some cache file got confused/corrupted at this point including data for both the old and new, changed table.

What is strange is that the database didn't show any signs of malfunction before that flush-command and it appeared that data was indeed added to the actual database. Also, in addition to data, also the two columns were missing from the table. After adding these back, the system worked fine but all the data typed in after the original table change is missing.

Everything (under the "/" in Linux server) is backed up on tape and theoretically I should be able to recover to the exact state of two days before the flush-command. In practice, however, this isn't the case, and even my personal backups that are more than 3 weeks old include the same corrupted MYD-file of that database (the size is something like 10k while it should be more than 1M).

I guess there isn't too much to do about the problem. However, I would like to know IF THERE ARE SOME OTHER FILES THAT MYSQL USES FOR SAVING/CACHING IN ADDITION TO MYI, FRM AND MYD FILES? If I would be able to restore these from the tape, could there be a slight chance of recovery of the system to the state before the flush-command? I have searched the system tmp-directory and database directories from the backup but I haven't found anything useful yet.

Please tell me if you have had any similiar problems and have recovered from them. Or if you think you have any information that could help me. Or if you know any other files MySQL uses for caching. Please DON'T tell me to upgrade to MySQL 4.x because after this it is already on our high-priority list

Thanks in advance and sorry if my english isn't perfect,

Yours,

darkfreak
Have you tried this:

http://www-fr.mysql.com/doc/de/REPAIR_TABLE.html

?
Reply With Quote
  #3 (permalink)  
Old 06-18-04, 05:30 AM
darkfreak's Avatar
darkfreak darkfreak is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Kuopio, Finland, Europe
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Worm
Sure! It complains that there should be 1700+ rows in the table but it can find only about 20 - and that's the number of the rows there is left after the repair. These are the rows that were added before the table was altered and not flushed.
Reply With Quote
  #4 (permalink)  
Old 06-18-04, 08:14 AM
Worm's Avatar
Worm Worm is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Germany, Frankfurt am Main
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by darkfreak
Sure! It complains that there should be 1700+ rows in the table but it can find only about 20 - and that's the number of the rows there is left after the repair. These are the rows that were added before the table was altered and not flushed.
Well, actually I'm not sure if mysql caches the data. I've never heard about this till now, in my opinion there have always been just logs or something. So good luck anyways
Reply With Quote
  #5 (permalink)  
Old 06-21-04, 12:30 AM
darkfreak's Avatar
darkfreak darkfreak is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Kuopio, Finland, Europe
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Worm
Well, actually I'm not sure if mysql caches the data. I've never heard about this till now, in my opinion there have always been just logs or something. So good luck anyways
From MySQL manual:

"...
FLUSH [LOCAL | NO_WRITE_TO_BINLOG] flush_option [, flush_option] ...
You should use the FLUSH statement if you want to clear some of the internal caches MySQL uses.
..."

In addition to index fiels, it seems there has to be a cache-file somewhere, because the db returned perfect results to queries before the FLUSH-command, altough the now missing data wasn't actually written neither to the MYI nor MYD file (as the file sizes - both current and backup - indicate).

Far as I have understood, these caches are written to actual files with the FLUSH command and/or when the server is shut down or restarted. Because of this, the user should not have to bother about this - UNLESS any table is to be aletered. In this case I hereby recommend to FLUSH before AND after the ALTER TABLE-command.

I guess the guy who altered the table didn't know exactly what he was doing, but I also think that this is a serious design error / bug in the MySQL (3.23.49) because the user can't be sure if the data is actually written to the db or left "on-the-air" unless (s)he constantly checks the sizes of the db-files. The FLUSH should be done automatically by the server in any case when needed. I haven't checked yet how this is done in later versions.

Thanks for answering and "listening"
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
layout templates: mysql or files tylerc PHP 1 05-21-04 11:30 PM
Classes and config files therat PHP 2 04-04-04 09:41 AM
PHP MySQL Huge files Targa Script Requests 0 02-29-04 12:39 PM
Adding binary files to mysql? angst ASP 0 07-03-03 08:56 AM


All times are GMT -5. The time now is 05:02 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.