From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A2BC61F9FE for ; Fri, 28 May 2021 00:07:57 +0000 (UTC) From: Eric Wong 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 Message-Id: <20210528000757.20500-4-e@80x24.org> In-Reply-To: <20210528000757.20500-1-e@80x24.org> References: <20210528000757.20500-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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(<execute($fid, $uid_uri->uid); + my ($oidbin) = $sth->fetchrow_array; + $oidbin ? unpack('H*', $oidbin) : undef; +} + +# FIXME: something with "lei " 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;