From: Jaime Casanova <systemguards@gmail.com>
To: mario.splivalo@mobart.hr
Cc: pgsql-sql@postgresql.org
Subject: Re: Changing the transaction isolation level within the stored procedure?
Date: Wed, 25 Jan 2006 11:46:12 -0500
Message-ID: <c2d9e70e0601250846u27ab1194sd01451a8a2c4d70d@mail.gmail.com> (raw)
In-Reply-To: <1138198348.8828.32.camel@localhost.localdomain>
References: <1138198348.8828.32.camel@localhost.localdomain>
> 1. java got the message via http (whatever)
> 2. java does: begin;
> 3. java does: select * from create_message(...)
> 4. java does some checking
> 5. java does: select * from set_message_status(...)
> 6. java does some more checing
> 7. java does commit; (under rare circumstances java does rollback).
>
>
> Another thread (thread B) does this:
>
> 1. java got the update_status_request via http (whatever)
> 2. java does: begin;
> 3. java does: select * from set_message_status(...)
> 4. java does: commit;
>
> As I've said, I'm using 'read commited', the default isolation level.
>
> Now, sometimes it happens that steps 4 or 6 take more time, and thread B
> steps are executed before steps in thread A have finished. So I would
> like the UPDATE in set_message_status to 'hold', until the transaction
> that previoulsy called the set_message_status have commited or rolled
> back.
>
> Is there a way to do so withing the postgres, or I need to do 'SET
> TRANSACTION ISOLATION LEVEL TO SERIALIZABLE' before step 2 in both
> thread A and thread B?
>
you need to set the transaction level after the begin and before every
other statement... after the begin you have a select that invoke your
function so that set is not the first statement...
--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: systemguards@gmail.com, mario.splivalo@mobart.hr
Subject: Re: Changing the transaction isolation level within the stored procedure?
In-Reply-To: <c2d9e70e0601250846u27ab1194sd01451a8a2c4d70d@mail.gmail.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