From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/6] lei_mail_sync: debug code for uncommitted txn
Date: Fri, 28 May 2021 00:07:54 +0000 [thread overview]
Message-ID: <20210528000757.20500-4-e@80x24.org> (raw)
In-Reply-To: <20210528000757.20500-1-e@80x24.org>
I'm not 100% sure why, but "lei up" seems to cause uncommitted
transaction errors. LeiToMail calls sto->set_sync_info, but
LeiXSearch should call sto->done and lms_commit, so I'm not
sure where the uncommited transaction is coming from...
---
lib/PublicInbox/LeiMailSync.pm | 33 +++++++++++++++++++++++++++++++++
lib/PublicInbox/LeiXSearch.pm | 3 +++
2 files changed, 36 insertions(+)
diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm
index d9c30580..2c071f5a 100644
--- a/lib/PublicInbox/LeiMailSync.pm
+++ b/lib/PublicInbox/LeiMailSync.pm
@@ -356,4 +356,37 @@ sub forget_folder {
$dbh->do('DELETE FROM folders WHERE fid = ?', undef, $fid);
}
+sub imap_oid {
+ my ($self, $lei, $uid_uri) = @_;
+ my $mailbox_uri = $uid_uri->clone;
+ $mailbox_uri->uid(undef);
+ warn "$uid_uri $mailbox_uri";
+ my $folders = [ $$mailbox_uri ];
+ if (my $err = $self->arg2folder($lei, $folders)) {
+ if ($err->{fail}) {
+ $lei->qerr("# no sync information for $mailbox_uri");
+ return;
+ }
+ $lei->qerr(@{$err->{qerr}}) if $err->{qerr};
+ }
+ my $fid = $self->{fmap}->{$folders->[0]} //=
+ _fid_for($self, $folders->[0]) // return;
+ my $sth = $self->{dbh}->prepare_cached(<<EOM, undef, 1);
+SELECT oidbin FROM blob2num WHERE fid = ? AND uid = ?
+EOM
+ $sth->execute($fid, $uid_uri->uid);
+ my ($oidbin) = $sth->fetchrow_array;
+ $oidbin ? unpack('H*', $oidbin) : undef;
+}
+
+# FIXME: something with "lei <up|q>" is causing uncommitted transaction
+# warnings, not sure what...
+sub DESTROY {
+ my ($self) = @_;
+ my $dbh = $self->{dbh} or return;
+ return if $dbh->{ReadOnly};
+ use Carp;
+ warn "BUG $$ $0 $self {dbh} UNCOMMITTED ", Carp::longmess();
+}
+
1;
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 3482082d..e2a8e8e3 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -357,6 +357,9 @@ sub query_done { # EOF callback for main daemon
if (my $lxs = delete $lei->{lxs}) {
$lxs->wq_wait_old(\&xsearch_done_wait, $lei);
}
+ if ($lei->{opt}->{'mail-sync'} && !$lei->{sto}) {
+ warn "BUG: {sto} missing with --mail-sync";
+ }
my $wait = $lei->{sto} ? $lei->{sto}->ipc_do('done') : undef;
$lei->{ovv}->ovv_end($lei);
my $start_mua;
next prev parent reply other threads:[~2021-05-28 0:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 10:49 [PATCH] lei: handle a single IMAP message in most places Eric Wong
2021-05-28 0:07 ` [PATCH 0/6] lei: odds and ends and a resend Eric Wong
2021-05-28 0:07 ` [PATCH 1/6] viewdiff: make $UNSAFE a variable Eric Wong
2021-05-28 0:07 ` [PATCH 2/6] viewdiff: escape '{' and '}' for regexp Eric Wong
2021-05-28 0:07 ` Eric Wong [this message]
2021-05-28 9:35 ` [PATCH 3/6] lei_mail_sync: debug code for uncommitted txn Eric Wong
2021-05-28 0:07 ` [PATCH 4/6] lei: mark reorder-and-rewrite-local-history as a TODO item Eric Wong
2021-05-28 0:07 ` [PATCH 5/6] lei: handle a single IMAP message in most places Eric Wong
2021-05-28 9:37 ` Eric Wong
2021-05-28 0:07 ` [PATCH 6/6] lei: add TODO item for FUSE mount Eric Wong
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=20210528000757.20500-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).