It seems there is a memory leak in Mojo::SQLite which showed itself in long running Minion workers. I mentioned it on the Minion::Backend::SQLite GitHub page as a possible leak in that module (see https://github.com/Grinnz/Minion-Backend-SQLite/issues/8), but it seems I've traced it back to Mojo::SQLite.
Anyway, I'll copy-paste part of it here:
Running this script:
use strict;
use Mojo::SQLite;
use Memory::Usage;
use v5.20;
my $mu = Memory::Usage->new;
my $sql = Mojo::SQLite->new('sqlite:/tmp/test.db');
$mu->record('before');
for(1..10000) {
$sql->db->query('select sqlite_version() as version');
}
$mu->record('after');
$mu->dump();
I believe commit a2d06a6 resolves this. For some reason re-setting the update hook whenever the dbh was dequeued again was causing a leak. (and also unnecessary work anyway)
Hello,
It seems there is a memory leak in
Mojo::SQLite
which showed itself in long running Minion workers. I mentioned it on theMinion::Backend::SQLite
GitHub page as a possible leak in that module (see https://github.com/Grinnz/Minion-Backend-SQLite/issues/8), but it seems I've traced it back toMojo::SQLite
.Anyway, I'll copy-paste part of it here:
Running this script:
Which results in:
As you can see the data diff has increased.
Simply calling
$sql->db
is enough for it to leak actually, no need to even execute a query.