pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ludwig Isaac Lim <ludz_lim@yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: PostgreSQL Mailing List <pgsql-admin@postgresql.org>
Subject: Re: Stuck Spinlock Error Message
Date: Mon, 4 Aug 2003 20:55:12 -0700 (PDT)
Message-ID: <20030805035512.67568.qmail@web21603.mail.yahoo.com> (raw)
In-Reply-To: <2213.1059698282@sss.pgh.pa.us>

Hi:

--- Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >      What can cause a stuck spinlock?
> In theory, that shouldn't ever happen.  Can you
> reproduce it?
> > 			regards, tom lane

   I could not reproduce it, but I'll describe how
error happen. I have a program that read a file large
file which 20,000 records and spawn a process that
execute a PLPGSQL stored function based on the content
of the file. 

    The following is a table of the SQL statement
generated:
    process 1         SELECT f1(120,  123.3);       
process 2         SELECT f1(120,   53.3);       
process 3         SELECT f1(120,   31.3);
    ..
    ..
    process n         SELECT f1(120,    2.3);

  the function f1 is basically defined as
  CREATE OR REPLACE FUNCTION f1(integer, float8)
  RETURN INTEGER
  AS'
  DECLARE
     -- some variable declaration  BEGIN
     -- Lock the table based on the first parameter
    -- of the stored function (use record level lock) 
   SELECT * 
     FROM   t1
     WHERE  field1 = $1
     FOR UPDATE;
     --a batch of SQL statements here --
  END;'
  LANGUAGE 'plpgsql';

  As you noticed the the first parameter of the called
function is the same (Due to bug on our program).
Since it performs a record level lock on the record,
the processes will queue (i.e. will execute if  only a
process relinquish its lock).   I'm guessing that the
there was just to many postmaster process trying to
concurrently trying to access the same record being
lock by a record-lock. When I execute the "top"
command in linux there are a lot of postmaster process
in the process list

   Is the spinlock error possible given that scenario?
Is this error related to the following error messages:
   fatal 2: cannot write block 3 of 16556/148333 blind
: too many open files in sysytem.

   Note : I was able to correct the above error
messages by increasing the file-max parameter in the
"sysctl.conf".

   I'm guessing that the spinlock error occurs after
there are around hundreds (or thousands) of queued
postmaster processes.

best regards,
ludwig


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com



view thread (5+ messages)  latest in thread

Message-ID: <20030805035512.67568.qmail@web21603.mail.yahoo.com>
Permalink:  ../20030805035512.67568.qmail@web21603.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030805035512.67568.qmail@web21603.mail.yahoo.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: ludz_lim@yahoo.com, tgl@sss.pgh.pa.us
  Subject: Re: Stuck Spinlock Error Message
  In-Reply-To: <20030805035512.67568.qmail@web21603.mail.yahoo.com>
  References: <2213.1059698282@sss.pgh.pa.us> <20030805035512.67568.qmail@web21603.mail.yahoo.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