Re: BUG #3242: FATAL: could not unlock semaphore: error code 298

From: Marcin Waldowski <M(dot)Waldowski(at)sulechow(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3242: FATAL: could not unlock semaphore: error code 298
Date: 2007-04-20 07:20:05
Message-ID: 462869A5.6080203@sulechow.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hello.

I've made some analysis of PostgreSQL code. It looks like void
PGSemaphoreUnlock(PGSemaphore sema) from backend\port\win32_sema.c was
executed one time more than needed.

Error code 298 means "Too many posts were made to a semaphore":
http://msdn2.microsoft.com/en-us/library/ms681382.aspx (sorry for
posting microsoft links ;))

Below is an example when it happens:
http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2004-02/0406.html

If I understand it correctly it means that function ReleaseSemaphore
(http://msdn2.microsoft.com/en-us/library/ms685071.aspx) which is
executed from PGSemaphoreUnlock, was executed one time more than needed.

I'm afraid than problem may lie above win32_sema.c :(

Regards, Marcin

Marcin Waldowski wrote:
> The following bug has been logged online:
>
> Bug reference: 3242
> Logged by: Marcin Waldowski
> Email address: M(dot)Waldowski(at)sulechow(dot)net
> PostgreSQL version: 8.2.3 and 8.2.1
> Operating system: Windows XP SP2
> Description: FATAL: could not unlock semaphore: error code 298
> Details:
>
> Hello.
>
> After some time of performace test of our aplication (50 concurrent database
> connections making lots of quick transactions with prepared statements) we
> found problem in PostgreSQL log - "could not unlock semaphore: error code
> 298". After that connections were hanged blocked on update operations.
>
> We are investigating problem now. What another information should we
> provide?
>
> Log from 8.2.1
> 2007-04-19 08:52:11 FATAL: could not unlock semaphore: error code 298
> 2007-04-19 08:52:11 STATEMENT: COMMIT
> 2007-04-19 08:52:11 WARNING: AbortTransaction while in COMMIT state
>
> Log from 8.2.3
> 2007-04-19 10:56:13 FATAL: could not unlock semaphore: error code 298
> 2007-04-19 10:56:13 STATEMENT: update sometable set a = a + $1, b = b + $2,
> c = c + $3 where id = $4
>
> Regards, Marcin
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Magnus Hagander 2007-04-20 07:51:10 Re: BUG #3242: FATAL: could not unlock semaphore: error code 298
Previous Message Tom Lane 2007-04-20 05:06:48 Re: BUG #3243: foreign key constraint not working?

Browse pgsql-hackers by date

  From Date Subject
Next Message Zoltan Boszormenyi 2007-04-20 07:27:46 Re: parser dilemma
Previous Message Tom Lane 2007-04-20 06:55:37 Re: Improving deadlock error messages