Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

unohuim's avatar

Job Batches Hanging

Hello everyone. I can't seem to find this specific issue previously.. my apologies if this was discussed already.

I'm new to jobs and batching. My app works fine without jobs, but obviously isn't ideal as the user waits a while. The task is basically iterating through each day and processing nhl hockey games per day. If I do this for a few days, zero issues (with jobs and batches). If I do this for longer than a month, things get dicey. Yesterday, I started receiving "no more storage on device" errors in my sentry. So I destroyed the 50gb hdd server on Forge and created a new one with 900 gb. Much better, but.. I still cannot access my job_batches table as it hangs forever and it only has 240 records. I can, however, access other tables with thousands of records no problem.

Am I doing jobs incorrectly? Do I need to manage storage or caching or something else that I'm not doing that's causing this? Below is the code where the "magic" happens.

Thanks in advance.

public function importPlayByPlaysByDate(string $date)
    {        
        $games = $this->getGamesByDate($date);
        $jobsPlayByPlay = [];
        $jobsShifts = [];
        $sumGames = [];

        foreach($games['games'] as $game) {
            $playByPlay = $this->getPlayByPlay($game['id']);
            $jobsPlayByPlay[] = new ImportGamePlayByPlaysJob($playByPlay);

            $shifts = $this->shiftsImporter->getShifts($game['id']);
            $jobsShifts[] = new ImportShiftsJob($shifts);

            $sumGames[] = new SumGameJob($playByPlay);

            //create the game summary
            //$this->sumGame($playByPlay);
            //append season statistics, including averages and /60s
        }

        Bus::chain([
            $batPlayByPlays = Bus::batch($jobsPlayByPlay)->name('Import Play By Plays - ' . $date),
            $batShifts = Bus::batch($jobsShifts)->name('Import Shifts - ' . $date),
            $batSums = Bus::batch($sumGames)->name('Summarize Games - ' . $date)
        ])->dispatch();
    }
0 likes
3 replies
unohuim's avatar

for clarification, I'm using the database driver. And when this eventually completes (even 3 months worth), my shifts, playbyplays, and game summaries tables are all completely done correctly. I simply cannot access the job_batches table even right now while this isn't even executing. If I do it for only 2 weeks back, I can, and I can watch the progress of the jobs and batches in real time. Thanks.

unohuim's avatar

Is it possible that I'm chaining incorrectly? Are we able to chain batches like I'm doing, or is chaining only available for jobs. I definitely want the playbyplays batch to finish before I begin the other batches.

Sergiu17's avatar

@unohuim Yes, you can dispatch a chain of batches. I don't know the right answer, but it seems like there are a lot of Jobs inside each batch..and this could be the issue.

How many elements are inside $jobsPlayByPlay, jobsShifts and $sumGames ?

Bus::chain is specific, it perform a lot of read, write and delete operations

Please or to participate in this conversation.