pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Inoue, Hiroshi <inoue@tpf.co.jp>
To: Craig Ringer <craig@2ndquadrant.com>
Cc: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: Re: msdtc with 32-bit app fails to resolve in-doubt or not-notifed transactions
Date: Sat, 21 Jun 2014 06:34:54 +0900
Message-ID: <53A4A8FE.6010901@tpf.co.jp> (raw)
In-Reply-To: <53A45B59.70303@2ndquadrant.com>
References: <53A45B59.70303@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>



(2014/06/21 1:03), Craig Ringer wrote:
> Hi folks
>
> I've found an issue with psqlODBC's MSDTC support and pgxalib.dll, where
> a 32-bit application on a 64-bit server will intermittently leave
> transactions in the "only failed to notify" state in MSDTC.
>
> This occurs when:
>
> - The application exits normally after its final ITransaction::Commit
> call returns but before MSDTC has invoked
> ITransactionResourceAsync::CommitRequest on the psqlODBC-provided
> IAsyncPG object; or
>
> - When the application or server crash after MSDTC Phase I but before
> Phase II.
>
> In both these cases the resource manager is supposed to handle
> transaction resolution. It uses pgxalib.dll for this as that's the
> registered XA co-ordinator for the resource type.
>
> I've been able to trace pgxalib.dll (which, btw, was painful, will
> follow up on that) and found that XAConnection::xa_recover() is being
> called on the transaction, as expected. It's calling into
> XAConnection::ActivateConnection, where it fails to establish an ODBC
> connection and bails out at the test at 142 after getting return code -1
> from SQLDriverConnect(...).
>
> http://msdn.microsoft.com/en-us/library/ms716219(v=vs.85).aspx
>
> suggests that this is SQL_ERROR. pgxalib.dll doesn't call SQLGetDiagRec
> or SQLGetDiagField to get any details and log them; I'll submit a
> separate patch for that.
>
> It took me a while to figure it out, but SQLDriverConnect is failing
> because it's using the name of the 32-bit driver,

Oops, it's my mistake. It may be better to rewrite the code completely
using libpq APIs instead of ODBC APIs.

> since it got the DSN
> from a 32-bit application. So there's no such driver as far as the
> 64-bit application is concerned.
>
> (It didn't help that I couldn't enable system-wide ODBC tracing on the
> system for unrelated and annoying as-yet-unresolved reasons with the
> ODBC driver manager).
>
> Anyway - it looks like it'll be necessary to figure out in pgxalib.dll
> when this is happening and remap the driver name. That seems pretty
> crude, though, so I'm looking for better ideas.
>
> I'll follow up when it's not midnight with:
>
> - a patch to add proper error diagnostics in pgxalib.dll on connection
> failure;
>
> - results of testing a hack that just mangles the dsn connection string
> manually, as a proof of concept to show that this is really the issue; and
>
> - If I can figure out how to do it the right way (as opposed to just
> abusing a breakpoint to set the lvalue on return like I ended up doing),
> some documentation on how to turn pgxalib tracing on.
>
>
> As part of this I've been wondering whether it's possible to deal with
> that exit race condition. I'm not sure how to tackle that - I don't
> speak fluent COM or OLE. Do you think it'd be legal to delay in the
> IAsyncPG dtor until either we confirm commit of an a tx we know is in
> flight or we hit a (short) timeout?
>


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



view thread (11+ messages)  latest in thread

Message-ID: <53A4A8FE.6010901@tpf.co.jp>
Permalink:  ../53A4A8FE.6010901@tpf.co.jp/
Also on:    postgresql.org/message-id/53A4A8FE.6010901@tpf.co.jp

 · 

reply

Reply instructions:

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

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: inoue@tpf.co.jp, craig@2ndquadrant.com
  Subject: Re: msdtc with 32-bit app fails to resolve in-doubt or not-notifed transactions
  In-Reply-To: <53A4A8FE.6010901@tpf.co.jp>
  References: <53A45B59.70303@2ndquadrant.com> <53A4A8FE.6010901@tpf.co.jp>

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

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox