Bug #56816 Table is marked as crashed and should be repaired
Submitted: 16 Sep 2010 11:26 Modified: 16 Oct 2010 15:03
Reporter: Shikha Chaudhry Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.41 OS:Microsoft Windows
Assigned to: CPU Architecture:Any

[16 Sep 2010 11:26] Shikha Chaudhry
Description:
We have developed an application using php, C++ and mysql. Our application has to be run 24 hours at a stretch. It is a very simple code, however, the sql table crashes quite often. The database contains 3 tables, out of which one only fails. The type of that table is MyISAM. 

The error which I get is as follows:

"Table is marked as crashed and should be repaired."

The code is as follows:

<?php
  include("dbconn.php");
                            
   $temp=array();
   $temp[1]="";
  
   $result= mysql_query("select * from temporary_tag_collection where upload_status=0 order by timestamp");
   
   while($row=mysql_fetch_array($result))
    {
        $temp_date=explode(" ",$row['timestamp']);  
        
        $query1=mysql_query("select count(*) as cnt from attendance where tag_id='".$row['tag_id']."' and `date`='".$temp_date[0]."' and status='y' and in_out_status=0"); 
        $count = mysql_fetch_assoc($query1);
        
        if($count["cnt"]!=0)
        {
            /*Update the time_out data*/  
            mysql_query("update attendance set time_out='".$row['timestamp']."',in_out_status=1 where tag_id='".$row['tag_id']."' and  in_out_status=0") or die(mysql_error()); 
      
            /*Change the URL */
            $url_n='http://abc.php?smartcard_id='.$row['tag_id']."&time_in=".urlencode($row['timestamp'])."&ip_address=".urlencode($_SERVER['REMOTE_ADDR'])."&in_out_status=1";
            $temp = file($url_n);
            echo $temp[1]; 
            
            if($temp[1]!="")
            mysql_query("update temporary_tag_collection set upload_status=1 where tag_id='".$row['tag_id']."'") or die(mysql_error()); 
        }
       
        else if($count['cnt']==0)
        {
            $set_in_out_status=0; //
                                     
            mysql_query("insert into attendance(tag_id,time_in,`date`,in_out_status) values('".$row['tag_id']."','".$row['timestamp']."','".$temp_date[0]."','".$set_in_out_status."')") or die(mysql_error());   
                
            $url_n='http://abc.php?smartcard_id='.$row['tag_id']."&time_in=".urlencode($row['timestamp'])."&ip_address=".urlencode($_SERVER['REMOTE_ADDR'])."&in_out_status=".$set_in_out_status;
            $temp = file($url_n);
                
            echo $temp[1]; 
                
            if($temp[1]!="")   
            mysql_query("update temporary_tag_collection set upload_status=1 where tag_id='".$row['tag_id']."'") or die(mysql_error());
        }
                          
        
    }
?>

Please help us in this regard.

How to repeat:
It is repeated after our system runs for more than 2-3 days at a stretch.
[16 Sep 2010 12:07] Susanne Ebrecht
Which MySQL version are you using?
[16 Sep 2010 13:48] Shikha Chaudhry
The version number is 5.1.41.
[16 Sep 2010 15:03] Valeriy Kravchuk
Please, send the results of SHOW CREATE TABLE and SHOW TABLE STATUS for the table in question. Also, please, send entire error log of MySQL server.
[16 Oct 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".