}, __PACKAGE__;
$self->{nshard} = count_shards($self) ||
nproc_shards({nproc => $opt->{jobs}});
- $self->{-no_fsync} = 1 if !$opt->{fsync};
- $self->{-dangerous} = 1 if $opt->{dangerous};
$self;
}
die "invalid indexlevel=$l\n";
$self->{indexlevel} = $l;
$self->{oidx} = PublicInbox::OverIdx->new($over_file, $opt);
- $self->{-no_fsync} = 1 if !$opt->{fsync};
- $self->{-dangerous} = 1 if $opt->{dangerous};
$self
}
File::Path::mkpath($mi_dir);
PublicInbox::Syscall::nodatacow_dir($mi_dir);
my $flags = $PublicInbox::SearchIdx::DB_CREATE_OR_OPEN;
- $flags |= $PublicInbox::SearchIdx::DB_NO_SYNC if $eidx->{-no_fsync};
- $flags |= $PublicInbox::SearchIdx::DB_DANGEROUS if $eidx->{-dangerous};
+ my $opt = $eidx->{-opt};
+ $flags |= $PublicInbox::SearchIdx::DB_NO_SYNC if !$opt->{fsync};
+ $flags |= $PublicInbox::SearchIdx::DB_DANGEROUS if $opt->{dangerous};
$json //= PublicInbox::Config::json();
bless {
mi_dir => $mi_dir,
sub new_file {
my ($class, $ibx, $opt) = @_;
- my $f;
my $rw = !!$opt;
- if (blessed($ibx)) {
- $f = $ibx->mm_file;
- $rw = 2 if $rw && $ibx->{-no_fsync};
- } else {
- $f = $ibx;
- }
+ my $f = blessed($ibx) ? $ibx->mm_file : $ibx;
return if !$rw && !-r $f;
my $self = bless { filename => $f }, $class;
- $self->{-opt} = $opt if $opt; # for WAL
+ $self->{-opt} = $opt if $opt; # for WAL and fsync
my $dbh = $self->{dbh} = PublicInbox::Over::dbh_new($self, $rw);
if ($rw) {
$dbh->begin_work;
PublicInbox::Syscall::nodatacow_dir($dir);
# owner == self for CodeSearchIdx
$self->{-set_has_threadid_once} = 1 if $owner != $self;
- $flag |= $DB_DANGEROUS if $owner->{-dangerous};
+ $flag |= $DB_DANGEROUS if $self->{-opt}->{dangerous};
}
}
return unless defined $flag;
- $flag |= $DB_NO_SYNC if $owner->{-no_fsync};
+ $flag |= $DB_NO_SYNC if !$self->{-opt}->{fsync};
my $xdb = eval { ($X->{WritableDatabase})->new($dir, $flag) };
croak "Failed opening $dir: $@" if $@;
$self->{xdb} = $xdb;
my ($class, $eidx, $shard) = @_;
my $self = bless {
eidx => $eidx,
+ -opt => $eidx->{-opt}, # hmm...
xpfx => $eidx->{xpfx},
indexlevel => $eidx->{indexlevel},
-skip_docdata => 1,
sub new {
my ($class, $v2w, $shard) = @_; # v2w may be ExtSearchIdx
my $ibx = $v2w->{ibx};
- my $self = $ibx ? $class->SUPER::new($ibx, 1, $shard)
+ my $self = $ibx ? $class->SUPER::new($ibx, $v2w->{-opt}, $shard)
: $class->eidx_shard_new($v2w, $shard);
# create the DB before forking:
$self->idx_acquire;
my $seen = 0;
$cfg->each_inbox(sub {
my ($ibx) = @_;
- $ibx->{-no_fsync} = 1;
my $im = PublicInbox::InboxWritable->new($ibx)->importer(0);
my $V = $ibx->version;
my @eml = (glob('t/*.eml'), 't/data/0001.patch');
my $scope = $lk->lock_for_scope;
my $pre_cb = delete $opt{pre_cb};
$pre_cb->($dir) if $pre_cb && $new;
- $opt{-no_fsync} = 1;
my $no_gc = delete $opt{-no_gc};
my $addr = $opt{address} // [];
$opt{-primary_address} //= $addr->[0] // "$ident\@example.com";
# limit each git repo (epoch) to 1GB or so
rotate_bytes => int((1024 * 1024 * 1024) / $PACKING_FACTOR),
last_commit => [], # git epoch -> commit
+ -opt => $creat_opt // {},
};
- $self->{oidx}->{-no_fsync} = 1 if $v2ibx->{-no_fsync};
$self->{shards} = count_shards($self) || nproc_shards($creat_opt);
bless $self, $class;
}
$new->{version} = 2;
my $creat_opt = { nproc => $opt->{jobs} };
$creat_opt->{wal} = 1 if $opt->{wal};
+$creat_opt->{fsync} = $opt->{fsync};
$new = PublicInbox::InboxWritable->new($new, $creat_opt);
-$new->{-no_fsync} = 1 if !$opt->{fsync};
my $v2w;
sub link_or_copy ($$) {
if ($opt->{compact} >= 2) {
PublicInbox::Xapcmd::run($ibx, 'compact', $opt->{compact_opt});
}
- $ibx->{-no_fsync} = 1 if !$opt->{fsync};
- $ibx->{-dangerous} = 1 if $opt->{dangerous};
$ibx->{-skip_docdata} //= $opt->{'skip-docdata'};
my $ibx_opt = $opt;
See public-inbox-purge(1) man page for full documentation.
EOF
-my $opt = { verbose => 1, all => 0, -min_inbox_version => 2 };
+my $opt = { verbose => 1, all => 0, -min_inbox_version => 2, fsync => 1 };
GetOptions($opt, @PublicInbox::AdminEdit::OPT, 'C=s@') or die $help;
if ($opt->{help}) { print $help; exit 0 };
foreach my $ibx (@ibxs) {
my $eml = PublicInbox::Eml->new($data);
- my $v2w = PublicInbox::V2Writable->new($ibx);
+ my $v2w = PublicInbox::V2Writable->new($ibx, $opt);
my $commits = $v2w->purge($eml) || [];
my $im;
if ($ibx->version == 2) {
require PublicInbox::V2Writable;
- $im = PublicInbox::V2Writable->new($ibx);
+ $im = PublicInbox::V2Writable->new($ibx, { fsync => 1 });
$im->{parallel} = 0; # pointless to be parallel for a single message
} else {
$im = PublicInbox::Import->new($git, $ibx->{name},
if ('reindex catches missed messages') {
my $v2ibx = $cfg->lookup_name('v2test');
- $v2ibx->{-no_fsync} = 1;
my $im = PublicInbox::InboxWritable->new($v2ibx)->importer(0);
my $cmt_a = $v2ibx->mm->last_commit_xap($schema_version, 0);
my $eml = eml_load('t/data/0001.patch');
if ('reindex catches content bifurcation') {
use PublicInbox::MID qw(mids);
my $v2ibx = $cfg->lookup_name('v2test');
- $v2ibx->{-no_fsync} = 1;
my $im = PublicInbox::InboxWritable->new($v2ibx)->importer(0);
my $eml = eml_load('t/data/message_embed.eml');
my $cmt_a = $v2ibx->mm->last_commit_xap($schema_version, 0);
use_ok 'PublicInbox::MiscIdx';
my ($tmp, $for_destroy) = tmpdir();
-my $eidx = { xpfx => "$tmp/eidx", -no_fsync => 1 }; # mock ExtSearchIdx
+my $eidx = { xpfx => "$tmp/eidx" }; # mock ExtSearchIdx
my $v1 = create_inbox 'hope', address => [ 'nope@example.com' ],
indexlevel => 'basic', -no_gc => 1, sub {
my ($im, $ibx) = @_;
inboxdir => $inboxdir,
name => 'test-v2purge',
version => 2,
- -no_fsync => 1,
-primary_address => 'test@example.com',
indexlevel => 'basic',
});
inboxdir => "$tmpdir/testbox",
name => $this,
version => $v,
- -no_fsync => 1,
-primary_address => 'test@example.com',
indexlevel => $level,
});
name => 'test-v1reindex',
-primary_address => 'test@example.com',
indexlevel => 'full',
- -no_fsync => 1,
};
my $mime = PublicInbox::Eml->new(<<'EOF');
From: a@example.com
inboxdir => "$inboxdir/v2",
name => 'test-v2writable',
version => 2,
- -no_fsync => 1,
-primary_address => 'test@example.com',
};
$ibx = PublicInbox::Inbox->new($ibx);
my $ibx = $cfg->lookup('test@example.com');
ok($ibx, 'inbox found');
$ibx->{version} = 2;
-$ibx->{-no_fsync} = 1;
my $v2w = PublicInbox::V2Writable->new($ibx, { nproc => 1 });
ok $v2w, 'v2w loaded';
$v2w->{parallel} = 0;
version => 2,
-primary_address => 'test@example.com',
indexlevel => 'full',
- -no_fsync => 1,
};
my $agpl = do {
open my $fh, '<', 'COPYING' or die "can't open COPYING: $!";
inboxdir => $inboxdir,
name => 'test-v2writable',
version => 2,
- -no_fsync => 1,
-primary_address => 'test@example.com',
};
$ibx = PublicInbox::Inbox->new($ibx);
watchspam = maildir:$spamdir
EOM
my $ibx = $cfg->lookup_name($v);
- $ibx->{-no_fsync} = 1;
ok($ibx, 'found inbox by name');
my $w = PublicInbox::Watch->new($cfg);
$cfg = PublicInbox::Config->new($cfg->{-f});
$ibx = $cfg->lookup_name($v);
- $ibx->{-no_fsync} = 1;
is($ibx->search->reopen->mset('b:spam')->size, 0, 'spam removed');
is_deeply [], [ grep !/^#/, @warn ], 'no warnings';
my $cfg = cfg_new $tmpdir, $orig;
my $ibx = $cfg->lookup_name('test');
ok($ibx, 'found inbox by name');
-$ibx->{-no_fsync} = 1;
PublicInbox::Watch->new($cfg)->scan('full');
my $total = scalar @{$ibx->over->recent};
address => [ "test-$i\@example.com" ],
url => [ "//example.com/test-$i" ],
version => 2,
- -no_fsync => 1,
});
$ibx->{indexlevel} = $indexlevel if $level_cfg ne '';
my $entry = <<EOF;