• 現在のQAアナリティクスのバージョン: 3.5.0.0で、サポートしている環境はすべてクリアしています。

    3日前から、「リアルタイム 概要」のページが変わりません。

    具体的には
    ?過去30分間のユーザー数が”6”のまま
    ?セッションリプレイは3日前のものが再生できる。
    ?おととい、昨日のアクセスが反映されない

    ヘルプ画面見て気になるのは、
    cron_status:
    Night>Make view file>Readers>Make
    となっています。

    感覚的で申し訳ないのですが、いままで動いていた夜間のバッチが止まってそこから復旧できない感じです。
    これを復旧させるには何をすればいいのか、ご存じの方はいらっしゃいませんか?

Viewing 6 replies - 1 through 6 (of 6 total)
  • 確かに夜間データ処理で止まっている様子ですね。

    何らかの理由で、サーバーがデータ処理できないのかもしれません。

    サーバーのエラーログに何か出ていますか?

    Thread Starter sw326022

    (@sw326022)

    ご返信ありがとうございます。
    とりいそぎ、止まったあたりから今朝までのログを見てみましたが、特に気になるようなエラーはありません。
    自サーバIPのエラーを確認しています。

    yetal11777

    (@yetal11777)

    サーバーエラーではなさそうなんですね。

    止まっているところは「Night>Make view file>Readers>Make」とのことなので、サイト訪問者データ関連ですかね…
    何か思い当たることはあったりしますでしょうか?

    cronコードを見ると、↓この工程になるかと思うのですが…

    case 'Night>Make view file>Readers>Make':
        $this->backup_prev_status( $cron_status );
    
        global $qahm_db;
    
        $save_s_id = 1;
        $save_e_id = 1;
        //search dir
        $allfiles = $this->wrap_dirlist( $vw_reader_dir );
        $beforefile = '';
        $beforestat = 0;
        $beforeend  = 0;
        if ($allfiles) {
            foreach ($allfiles as $file) {
                $filename = $file['name'];
                if (is_file($vw_reader_dir . $filename)) {
                    $tmpary = explode('_', $filename);
                    $reader_ids = explode('-', $tmpary[0]);
                    if ( $save_s_id < $reader_ids[0] ) {
                        $save_s_id = $reader_ids[0];
                    }
    
                    if ($save_e_id < $reader_ids[1]) {
                        $save_e_id = $reader_ids[1];
                    }
                }
                if ( $reader_ids[0] === $beforestat && $beforeend < $reader_ids[1]) {
                    if ($beforefile) {
                        $wp_filesystem->delete( $vw_reader_dir . $beforefile);
                    }
                }
                $beforefile = $filename;
                $beforestat = $reader_ids[0];
                $beforeend  = $reader_ids[1];
            }
        }
    
        //現在の最終IDを調査
        $table_name = $wpdb->prefix . 'qa_readers';
        $query      = 'SELECT reader_id FROM ' . $table_name . ' order by reader_id asc limit 1';
        $stat_id    = $wpdb->get_var( $query );
    
        $query      = 'SELECT reader_id FROM ' . $table_name . ' order by reader_id desc limit 1';
        $last_id    = $wpdb->get_var( $query );
    
        if ( $save_s_id < $stat_id ) {
            $save_s_id = $stat_id;
        }
        $lastdist   = $last_id - $save_s_id;
        if ( $lastdist <= self::VIEW_READERS_MAX_IDS ) {
            if ( $save_e_id !== $last_id ) {
                //最終IDだけ保存すればOK
                $query      = 'SELECT * FROM ' . $table_name . ' WHERE reader_id between %d AND %d';
                $preobj     = $wpdb->prepare( $query,  $save_s_id, $last_id );
                $allrecord  = $qahm_db->get_results( $preobj );
    
                //既存のファイルをオープンし、新しくカラムを追加して保存する
                $oldfile = $save_s_id . '-' . $save_e_id . '_readers.php';
                $newfile = $save_s_id . '-' . $last_id . '_readers.php';
                if ( $wp_filesystem->exists( $vw_reader_dir.$oldfile) ) {
                    $oldary = $this->wrap_get_contents($vw_reader_dir . $oldfile);
                    $newary = [];
                    $newary[] = $oldary;
                    foreach ($allrecord as $row ) {
                        if ( $save_e_id < $row->reader_id) {
                            $newary[] = $row;
                        }
                    }
                    $this->wrap_put_contents( $vw_reader_dir . $newfile, $this->wrap_serialize( $newary ) );
                    if ( $newfile !== $oldfile ) {
                        $wp_filesystem->delete( $vw_reader_dir.$oldfile );
                    }
                } else {
                    $this->wrap_put_contents( $vw_reader_dir . $newfile, $this->wrap_serialize( $allrecord ) );
                }
            }
        } else {
            //最後まで保存ループが必要
            $is_last = false;
            while ( ! $is_last ) {
                $now_lastid = $save_s_id + self::VIEW_READERS_MAX_IDS;
                if ( $last_id < $now_lastid) {
                    $now_lastid = $last_id;
                    $is_last    = true;
                }
                $query      = 'SELECT * FROM ' . $table_name . ' WHERE reader_id between %d AND %d';
                $preobj     = $wpdb->prepare( $query,  $save_s_id, $now_lastid );
                $allrecord  = $qahm_db->get_results( $preobj );
    
                $allcount   = count($allrecord);
                $dbstatid   = $allrecord[0]->reader_id;
                $dblastid   = $allrecord[$allcount -1]->reader_id;
    
                //新しく保存する
                $newfile = $dbstatid . '-' . $dblastid . '_readers.php';
                $this->wrap_put_contents( $vw_reader_dir . $newfile, $this->wrap_serialize( $allrecord ) );
                //値を進める
                $save_s_id = $dblastid + 1;
            }
        }
        $cron_status = 'Night>Make view file>Readers>End';
        $this->set_next_status( $cron_status );
        $while_continue = false;
        break;

    あとは例えば
    ?DBテーブルの「{wp-prefix}_qa_readers」なども使われているので、その辺りとか…
    ?定数「VIEW_READERS_MAX_IDS ? ? = 50000」となっているので、その辺りとか…

    Thread Starter sw326022

    (@sw326022)

    @yetal11777さん

    ご返信ありがとうございました。

    ?何か思い当たること
    wordpress全体で他のバッチ処理が追加されたことくらいでしょうか。
    QAには直接関係ないです。

    ?定数「VIEW_READERS_MAX_IDS = 50000」
    これはあり得ます。

    とにかくリアルタイムビューが動かないのは困るので、最終的にはデータは放棄してプラグインを削除して再インストールくらいしか手がないのかなと思っています。

    yetal11777

    (@yetal11777)

    ?定数「VIEW_READERS_MAX_IDS = 50000」
    これはあり得ます。

    なるほど。プラグイン開発者にこんなケースがあるみたいと言っておきますねー(ホントに話すだけになっちゃうかもですが…直接の解決方法がわからずごめんなさい。)

    きっとプラグインの無効化→有効化はもう試されていますよね…今回とは異なるケースだとは思うのですが、一応こんなのもあったので↓書くだけ書いてみたりして。。
    https://mem.quarka.org/manual/realtime-trable/

    • This reply was modified 1 year ago by yetal11777.
    Thread Starter sw326022

    (@sw326022)

    @yetal11777さん

    ご返信ありがとうございます。

    ?プラグインの無効化→有効化
    これはやってみたのですが、どうも変わらないかったです。

    ?サーバによって1Gを認識しない
    うわあ、こんなこともあるんですね。ちょっと試してみます。

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘リアルタイムビューの過去30分間のユーザー数が変わらない’ is closed to new replies.