]> Sergey Matveev's repositories - public-inbox.git/commitdiff
msgmap: tmp_clone: use in-memory journal
authorEric Wong <e@yhbt.net>
Mon, 25 May 2020 03:30:20 +0000 (03:30 +0000)
committerEric Wong <e@yhbt.net>
Tue, 26 May 2020 10:54:39 +0000 (10:54 +0000)
This prevents $TMPDIR from being littered with *-journal files
after running the test suite.

This shouldn't cause excessive memory use since $v2w->{mm_tmp}
doesn't see big transactions.  There's no need to worry about
data loss, here,either, since this is just a temporary clone
we've even disabled fsync on.

Fixes: 78888d36fb80889f ("msgmap: use TRUNCATE for journal_mode, for now")
lib/PublicInbox/Msgmap.pm

index 5fe14383ac484a79e1b279b718e28db68b5449d4..a2ffe7203e74c026af8675fea0922c026740f7f7 100644 (file)
@@ -70,6 +70,7 @@ sub tmp_clone {
        $self->{dbh}->sqlite_backup_to_file($fn);
        my $tmp = ref($self)->new_file($fn, 1);
        $tmp->{dbh}->do('PRAGMA synchronous = OFF');
+       $tmp->{dbh}->do('PRAGMA journal_mode = MEMORY');
        $tmp->{tmp_name} = $fn; # SQLite won't work if unlinked, apparently
        $tmp->{pid} = $$;
        close $fh or die "failed to close $fn: $!";