Unix Technical Forum

Re: regarding threads and transactions - problem 2

This is a discussion on Re: regarding threads and transactions - problem 2 within the Pgsql General forums, part of the PostgreSQL category; --> On Fri, Aug 26, 2005 at 01:28:51PM +0530, Surabhi Ahuja wrote: > Dear All, > > This is in ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 05:40 AM
Martijn van Oosterhout
 
Posts: n/a
Default Re: regarding threads and transactions - problem 2

On Fri, Aug 26, 2005 at 01:28:51PM +0530, Surabhi Ahuja wrote:
> Dear All,
>
> This is in reference to a problem which I had put up sometime back.
> Please take some time to study it
>
> The piece of code that i am trying to execute is attached (itsa cpp file)
> The stored procedure (that the program calls) insert_patient is as follows:


Firstly, this has nothing to do with threads. Any programs executing
this in parallel would have the same problem.

> Please check the block in red. Why is it happening? insnt the call to thestored procedure considered one atomic operation?
> Please tell me what is going wrong?
>
> Cant I avoid such red blocks? and get messages like the ones obained fromthe other threads
> I can impose locks but would not that lower down the performance?
> Please suggest other solutions


Well, you guarentee atomicity by using locks. And yes, locks do
decrease performance overall. Since you don't take any locks the
procedure can execute in parallel with anything else.

Your options are:
1. Lock the table in the procedure
2. Change to using a system that doesn't require such a strange update
procedure.
3. Trap the error and retry.

Option 2 would be the best, though option 3 would be faster than
option 1.

Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFDDs56IB7bNG8LQkwRAh7QAJ9AESzc55V67FoLyPwWoq qcjdSkjwCdG3kI
BMJINbW1LD82/jMCSlKXtms=
=JqPU
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:32 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com