• Hi,

    I started having a problem with mysqld.exe using 100% of CPU.

    I ran ‘SHOW FULL PROCESSLIST;’ and I got below query running and never ending:

    SELECT SQL_CALC_FOUND_ROWS  kconl_posts.ID FROM kconl_posts  INNER JOIN kconl_postmeta ON ( kconl_posts.ID = kconl_postmeta.post_id )  INNER JOIN kconl_postmeta AS mt1 ON ( kconl_posts.ID = mt1.post_id )  INNER JOIN kconl_postmeta AS mt2 ON ( kconl_posts.ID = mt2.post_id )  INNER JOIN kconl_postmeta AS mt3 ON ( kconl_posts.ID = mt3.post_id )  INNER JOIN kconl_postmeta AS mt4 ON ( kconl_posts.ID = mt4.post_id )  INNER JOIN kconl_postmeta AS mt5 ON ( kconl_posts.ID = mt5.post_id )  INNER JOIN kconl_postmeta AS mt6 ON ( kconl_posts.ID = mt6.post_id )  INNER JOIN kconl_postmeta AS mt7 ON ( kconl_posts.ID = mt7.post_id )  INNER JOIN kconl_postmeta AS mt8 ON ( kconl_posts.ID = mt8.post_id )  INNER JOIN kconl_postmeta AS mt9 ON ( kconl_posts.ID = mt9.post_id )  INNER JOIN kconl_postmeta AS mt10 ON ( kconl_posts.ID = mt10.post_id )  INNER JOIN kconl_postmeta AS mt11 ON ( kconl_posts.ID = mt11.post_id )  INNER JOIN kconl_postmeta AS mt12 ON ( kconl_posts.ID = mt12.post_id )  INNER JOIN kconl_postmeta AS mt13 ON ( kconl_posts.ID = mt13.post_id ) WHERE 1=1  AND ( 
      ( kconl_postmeta.meta_key = 'routine_action' AND kconl_postmeta.meta_value IN ('task_scheduler_action_delete_task_log') ) 
      AND 
      ( mt1.meta_key = 'occurrence' AND mt1.meta_value IN ('constant') ) 
      AND 
      ( mt2.meta_key = '_max_root_log_count' AND mt2.meta_value IN ('0') ) 
      AND 
      ( mt3.meta_key = '_target_task_id' AND mt3.meta_value IN ('3277') ) 
      AND 
      ( mt4.meta_key = '_max_root_log_count_of_the_target' AND mt4.meta_value IN ('10') ) 
      AND 
      ( mt5.meta_key = 'owner_task_id' AND mt5.meta_value IN ('3277') ) 
      AND 
      ( mt6.meta_key = 'parent_routine_log_id' AND mt6.meta_value IN ('0') ) 
      AND 
      ( mt7.meta_key = '_max_execution_time' AND mt7.meta_value IN ('120') ) 
      AND 
      ( mt8.meta_key = '_force_execution' AND mt8.meta_value IN ('0') ) 
      AND 
      ( mt9.meta_key = '_hung_routine_handle_type' AND mt9.meta_value IN ('0') ) 
      AND 
      ( mt10.meta_key = '_yoast_wpseo_content_score' AND mt10.meta_value IN ('30') ) 
      AND 
      ( mt11.meta_key = 'custom_action' AND mt11.meta_value IN ('my_custom_action') ) 
      AND 
      ( mt12.meta_key = '_qts_slug_da' AND mt12.meta_value IN ('rz_test_task') ) 
      AND 
      ( mt13.meta_key = '_qts_slug_en' AND mt13.meta_value IN ('rz_test_task') )
    ) AND kconl_posts.post_type IN ('ts_task', 'ts_routine', 'ts_thread') AND ((kconl_posts.post_status = 'publish' OR kconl_posts.post_status = 'private')) GROUP BY kconl_posts.ID ORDER BY kconl_posts.post_date DESC, kconl_posts.ID DESC LIMIT 0, 1

    This is on the local server. CPU first is at around 30%, then it gets higher and higher. It reaches 100% and then my programs crash.

    I believe this query is run by Task Scheduler plug in.

    What step can I take to find the problem?

    Thanks

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter RolandasZa

    (@rolandasza)

    hi @miunosoft

    sorry for delay.

    I removed all tasks and created new one, with action Debug.

    it looks like CPU is steady now and I don’t get that never-ending query.

    so, what could be the problem? how can I make my task run with no problems? ??

    Plugin Author miunosoft

    (@miunosoft)

    So your custom action is something to do with the problem.

    I’d like to see how you created your custom action. Can you post the code?

    Thread Starter RolandasZa

    (@rolandasza)

    I did it very simple- write the current date/time into a custom table in the database.

    add_filter( 'my_custom_action', 'doMyCustomAction', 10, 2 );
    function doMyCustomAction( $isExitCode, $oRoutine )
    {
        global $wpdb;
        $wpdb->insert($wpdb->prefix.'cron_test', array('data' => date('Y/m/d H:i:s')) );
    
        TaskScheduler_Debug::log( $oRoutine->getMeta() );
        return 1;
    }
    Plugin Author miunosoft

    (@miunosoft)

    Can you test this?

    
    add_filter( 'my_custom_action', 'doMyCustomAction', 10, 2 );
    function doMyCustomAction( $isExitCode, $oRoutine )
    {
        global $wpdb;
        TaskScheduler_Debug::log( 'called' );
        $_sTableName = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->prefix . 'cron_test' ) ) );
        TaskScheduler_Debug::log( 'Table Name: ' . $_sTableName );
        if ( ! $_sTableName ) {
            return 0;
        }
        $wpdb->insert($wpdb->prefix . 'cron_test', array( 'data' => date('Y/m/d H:i:s') ) );
        TaskScheduler_Debug::log( $oRoutine->getMeta() );
        return 1;
    
    }
    

    Then run the task and check the created log to see how long it takes between log items. You can post the log here.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Mysql uses 100% of CPU’ is closed to new replies.