[Psycopg] PATCH: two phase commit

Federico Di Gregorio fog at initd.org
Fri Jan 18 11:18:43 CET 2008


Il giorno ven, 18/01/2008 alle 18.05 +0900, James Henstridge ha scritto:
> On 18/01/2008, Federico Di Gregorio <fog at initd.org> wrote:
> I've sent an email to the db-sig mailing list about this now:
>     http://mail.python.org/pipermail/db-sig/2008-January/005290.html

Read.

> I am not convinced that separating off the transaction commit API from
> the connection is not a good idea.
> 
> At one level, I am not hugely concerned by the API, since it is
> unlikely to be used by many programmers -- instead only being used by
> glue code that hooks the database connection into the transaction
> manager (which is often DB specific anyway).

This is true.

> I did take a look for existing adapters for ideas and found two others:
> 
> The kinterbasdb module adds a prepare() method to the connection
> object.  After calling this method, the standard commit() and
> rollback() methods can be used to perform the second phase of the
> commit.  This would be implementable in psycopg2, with the following
> caveats:
>  1. we'd need to be able to generate unique transaction identifiers.
>  2. it provides no way to commit a transaction prepared with another connection.

First of all we can't user prepare() because that should be reserved for
prepared statements. prepare_transaction() or even the very explicit
prepare_current_transaction() (that is exactly what the method does) are
fine. The ability to generate XID is undubtely useful.

The question is, we want to "lock" the connection untill the current
prepared transaction is commited or we want to give the client the
ability to set aside prepared transactions and execute them from a
different connection? If nobody need the second one the first option is
"safe"; you can even abort the currently prepared transaction on object
dealloc.

federico 

p.s. did you find M.A.L. answer confusing? I did.. :/

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog at debian.org
INIT.D Developer                                           fog at initd.org
  Gli avvoltoi cinesi si nutrono di arte, ma possono anche mangiare
   i `domani'.                                        -- Haruki Murakami
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio
	firmata digitalmente
Url : http://lists.initd.org/pipermail/psycopg/attachments/20080118/2b3da8fb/attachment.pgp 


More information about the Psycopg mailing list