Skip to main content
Added deadlock tag since question is about deadlocks
Link
RolandoMySQLDBA
  • 184.3k
  • 33
  • 323
  • 531
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

We are running a cron job (daily basis), it needs more time to complete because complex calculation is running in the huge database. When a user register or login to the system, then shows the above error. I just look herehere and herehere dealing with the same error, but i didn't get the exact solution. We are doing lot of SELECT / UPDATE / INSERT

We are running a cron job (daily basis), it needs more time to complete because complex calculation is running in the huge database. When a user register or login to the system, then shows the above error. I just look here and here dealing with the same error, but i didn't get the exact solution. We are doing lot of SELECT / UPDATE / INSERT

We are running a cron job (daily basis), it needs more time to complete because complex calculation is running in the huge database. When a user register or login to the system, then shows the above error. I just look here and here dealing with the same error, but i didn't get the exact solution. We are doing lot of SELECT / UPDATE / INSERT

Tweeted twitter.com/#!/StackDBAs/status/127642040040304640
added 4 characters in body
Source Link
Ashok KS
  • 173
  • 2
  • 7
public function getAllUplineId($id,$i,$position,$profile_field_id){
$select = "SELECT father_id
            FROM ft_individual161_ft_individual
            WHERE id=$id ";
$result = db_query($select);    
while($node = db_fetch_object($result))
    {
    $user_id = $node->father_id;   
    if($user_id > 0)
        {
        $amount = 1;        
        $this->update_profile_value($user_id,$profile_field_id,$amount);
        $i=$i+1;         
        $this->getAllUplineId($user_id,$i,$position,$profile_field_id);
        }
    
    }
}

public function update_profile_value($user_id,$profile_field_id,$amount){
$query = "UPDATE 161_ft_individual SET total_leg=total_leg+$amount
            WHERE id='$user_id' LIMIT 1";
$result = db_query($query);    
return $result;
}
public function getAllUplineId($id,$i,$position,$profile_field_id){
$select = "SELECT father_id
            FROM ft_individual
            WHERE id=$id ";
$result = db_query($select);    
while($node = db_fetch_object($result))
    {
    $user_id = $node->father_id;   
    if($user_id > 0)
        {
        $amount = 1;        
        $this->update_profile_value($user_id,$profile_field_id,$amount);
        $i=$i+1;         
        $this->getAllUplineId($user_id,$i,$position,$profile_field_id);
        }
    
    }
}

public function update_profile_value($user_id,$profile_field_id,$amount){
$query = "UPDATE 161_ft_individual SET total_leg=total_leg+$amount
            WHERE id='$user_id' LIMIT 1";
$result = db_query($query);    
return $result;
}
public function getAllUplineId($id,$i,$position,$profile_field_id){
$select = "SELECT father_id
            FROM 161_ft_individual
            WHERE id=$id ";
$result = db_query($select);    
while($node = db_fetch_object($result))
    {
    $user_id = $node->father_id;   
    if($user_id > 0)
        {
        $amount = 1;        
        $this->update_profile_value($user_id,$profile_field_id,$amount);
        $i=$i+1;         
        $this->getAllUplineId($user_id,$i,$position,$profile_field_id);
        }
    
    }
}

public function update_profile_value($user_id,$profile_field_id,$amount){
$query = "UPDATE 161_ft_individual SET total_leg=total_leg+$amount
            WHERE id='$user_id' LIMIT 1";
$result = db_query($query);    
return $result;
}
included image and grammar
Source Link
Derek Downey
  • 23.5k
  • 11
  • 78
  • 104
Loading
Table structure added
Source Link
Ashok KS
  • 173
  • 2
  • 7
Loading
deleted 5 characters in body
Source Link
Ashok KS
  • 173
  • 2
  • 7
Loading
added 1 characters in body
Source Link
Ashok KS
  • 173
  • 2
  • 7
Loading
Server details and error added
Source Link
Ashok KS
  • 173
  • 2
  • 7
Loading
Source Link
Ashok KS
  • 173
  • 2
  • 7
Loading