unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/4] over: use only supported and safe SQLite APIs
Date: Thu,  5 Apr 2018 21:45:27 +0000	[thread overview]
Message-ID: <20180405214528.19403-4-e@80x24.org> (raw)
In-Reply-To: <20180405214528.19403-1-e@80x24.org>

Some of this jankiness was from early performance problems
and they turned out to be unnecessary measures.
---
 lib/PublicInbox/OverIdx.pm    |  9 ---------
 lib/PublicInbox/V2Writable.pm |  3 +--
 script/public-inbox-compact   | 13 +++++--------
 3 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index 0e43aab..5c20f1f 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -14,21 +14,12 @@ use DBI qw(:sql_types); # SQL_BLOB
 sub dbh_new {
 	my ($self) = @_;
 	my $dbh = $self->SUPER::dbh_new;
-	$dbh->do('PRAGMA synchronous = OFF'); # commit_fsync instead
 	$dbh->do('PRAGMA journal_mode = TRUNCATE');
 	$dbh->do('PRAGMA cache_size = 80000');
 	create_tables($dbh);
 	$dbh;
 }
 
-sub commit_fsync {
-	my $fn = $_[0]->{filename};
-	if (open my $fh, '+<', $fn) {
-		$fh->sync;
-		close $fh;
-	}
-}
-
 sub get_counter ($$) {
 	my ($dbh, $key) = @_;
 	my $sth = $dbh->prepare_cached(<<'', undef, 1);
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index b858dcc..a8117aa 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -397,7 +397,7 @@ sub checkpoint {
 # issue a write barrier to ensure all data is visible to other processes
 # and read-only ops.  Order of data importance is: git > SQLite > Xapian
 sub barrier {
-	my ($self, $fsync) = @_;
+	my ($self) = @_;
 
 	if (my $im = $self->{im}) {
 		$im->barrier;
@@ -416,7 +416,6 @@ sub barrier {
 		$_->remote_barrier foreach @$parts;
 
 		$over->barrier_wait; # wait for each Xapian partition
-		$over->commit_fsync if $fsync;
 
 		# last_commit is special, don't commit these until
 		# remote partitions are done:
diff --git a/script/public-inbox-compact b/script/public-inbox-compact
index b8aaa4b..43e9460 100755
--- a/script/public-inbox-compact
+++ b/script/public-inbox-compact
@@ -36,15 +36,12 @@ sub commit_changes ($$$) {
 	my ($im, $old, $new) = @_;
 	my @st = stat($old) or die "failed to stat($old): $!\n";
 
-	for my $suf (qw(.pipe.lock -journal)) {
-		my $orig = "$old/over.sqlite3$suf";
-		link($orig, "$new/over.sqlite3$suf") and next;
-		next if $!{ENOENT};
-		die "failed to link $orig => $new/over.sqlite3$suf: $!\n";
+	my $over = "$old/over.sqlite3";
+	if (-f $over) {
+		require PublicInbox::Over;
+		$over = PublicInbox::Over->new($over);
+		$over->connect->sqlite_backup_to_file("$new/over.sqlite3");
 	}
-	link("$old/over.sqlite3", "$new/over.sqlite3") or die
-		"failed to link {$old => $new}/over.sqlite3: $!\n";
-
 	rename($old, "$new/old") or die "rename $old => $new/old: $!\n";
 	chmod($st[2] & 07777, $new) or die "chmod $old: $!\n";
 	rename($new, $old) or die "rename $new => $old: $!\n";
-- 
EW


  parent reply	other threads:[~2018-04-05 21:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05 21:45 [PATCH 0/4] a few more v2 updates Eric Wong (Contractor, The Linux Foundation)
2018-04-05 21:45 ` [PATCH 1/4] v2writable: allow tracking parallel versions Eric Wong (Contractor, The Linux Foundation)
2018-04-05 21:45 ` [PATCH 2/4] v2writable: refer to git each repository as "epoch" Eric Wong (Contractor, The Linux Foundation)
2018-04-05 21:45 ` Eric Wong (Contractor, The Linux Foundation) [this message]
2018-04-05 21:45 ` [PATCH 4/4] search: index and allow searching by date-time Eric Wong (Contractor, The Linux Foundation)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180405214528.19403-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).