itsgoingd / itsgoingd/clockwork

Clockwork\Request\Log::log will grow its log indefinitely resulting in a memory leak

Open
#518 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
6k
Forks
333
Avg merge
5m
Merged PRs (30d)
1

Description

When handling a lot of events during a longer process, php will run out of memory because all log messages are kept in memory. This is an issue for us as we expect the process to be alive for potentially millions of events.

Our current solution uses a wrapper around clockwork's logger, accesses the public property $messages that's available on clockworks's class and only keep the last 100:

$log = $this->clockwork->log();
if ($log instanceof Log === false) {
	throw new \LogicException("Expected log to be of type Clockwork\Request\Log");
}
$log->log($level, $message, $data);
if (count($log->messages) > self::MAX_LOG_SIZE) {
	array_shift($log->messages);
}

This works, but maybe it would be worth to consider including this (optional) behaviour out of the box.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Clockwork\Request\Log::log and inspect how messages are retained in the public messages property. Determine how an optional retention limit could fit the existing logging behavior, then verify that long-running processes no longer keep an unbounded log while the default behavior remains clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.