pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Swan <tswan@idigx.com>
To: Raj Mathur <raju@linux-delhi.org>
Cc: pgsql-admin@postgresql.org
Subject: Re: Transactions and HTTP
Date: Tue, 21 Jan 2003 14:15:54 -0600
Message-ID: <3E2DAA7A.60009@idigx.com> (raw)
In-Reply-To: <15916.52618.390720.567048@mail.linux-delhi.org>
References: <15916.52618.390720.567048@mail.linux-delhi.org>

Raj Mathur wrote:

>Hi,
>
>Writing a web-based application using PostgreSQL as the back-end
>database.  The master create functions look something like this:
>
>1. Accept ID from user.
>
>2. Verify that ID doesn't exist in database.  Start transaction.
>Create blank record with ID as key.
>
>3. Accept remaining data for record from user.
>
>4. Enter data into newly-created blank record.  End transaction.
>
>Firstly,is it possible to have a transaction spanning multiple
>instances of the CGI/mod_perl invocations?
>
Not easily.  You are not always guaranteed the same httpd process when 
connecting.  HTTP is stateless.

>Second, there are issues if the user session terminates for some
>reason (e.g. user goes offline after the blank record has been
>created, etc.) and I end up with a locked blank record in the
>database.  Would appreciate pointers to best practises in handling
>this paradigm.
>
It is basically a poor design when using HTTP operations.  You are 
better off using server-side session data to store all the information 
you will need for the complete database operation and then at your final 
stage of data entry do the record addtion inside of a transaction (i.e. 
one POST operation), if you want to rollback on error.  This should 
eliminate your concerns over lost locks and hanging transactions.

>Unrelated, but I find at least 3 different interfaces to PostgreSQL
>from Perl: DBI, Pg and PgSQL.  I'm using Pg at the moment, since that
>ships with PgSQL by default with Red Hat, but are there any reasons to
>choose one over the other?
>
>Regards,
>
>-- Raju
>  
>





view thread (4+ messages)  latest in thread

Message-ID: <3E2DAA7A.60009@idigx.com>
Permalink:  ../3E2DAA7A.60009@idigx.com/
Also on:    postgresql.org/message-id/3E2DAA7A.60009@idigx.com

 · 

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-admin@postgresql.org
  Cc: tswan@idigx.com, raju@linux-delhi.org
  Subject: Re: Transactions and HTTP
  In-Reply-To: <3E2DAA7A.60009@idigx.com>
  References: <15916.52618.390720.567048@mail.linux-delhi.org> <3E2DAA7A.60009@idigx.com>

* 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