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

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: [BUGS] BUG #3242: FATAL: could not unlock semaphore: error code 298
Дата
Msg-id 462BAEE2.2040904@hagander.net
обсуждение исходный текст
Ответ на Re: [BUGS] BUG #3242: FATAL: could not unlock semaphore: error code 298  (Marcin Waldowski <M.Waldowski@sulechow.net>)
Список pgsql-hackers
Marcin Waldowski wrote:
> Magnus Hagander wrote:
>> Tom Lane wrote:
>>
>>> Magnus Hagander <magnus@hagander.net> writes:
>>>
>>>> No, it's definitly the right primitive. But we're creating it with a
>>>> max
>>>> count of 1.
>>>>
>>> That's definitely wrong.  There are at least three reasons for a PG
>>> process's semaphore to be signaled (heavyweight lock release, LWLock
>>> release, pin count waiter), and at least two of them can occur
>>> concurrently (eg, if deadlock checker fires, it will need to take
>>> LWLocks, but there's nothing saying that the original lock won't be
>>> released while it waits for an LWLock).
>>>
>>> The effective max count on Unixen is typically in the thousands,
>>> and I'd suggest the same on Windows unless there's some efficiency
>>> reason to keep it small (in which case, maybe ten would do).
>>>
>>
>> AFAIK there's no problem with huge numbers (it takes an int32, and the
>> documentation says nothing about a limit - I'm sure it's just a 32-bit
>> counter in the kernel). I'll give that a shot.
>>
>
> Magnus, Tom, thank you for finding what causes the problem :) I hope
> that was also a reason why other transactions were hung (because that is
> a prior, I think).
>
>> Marcin - can you test a source patch? Or should I try to build you a
>> binary for testing? It'd be good if you can confirm that it works before
>> we commit anything, I think.
>>
>
> Of course I will check fix :) I will be able to do tests on monday. I
> think source path should be enought, despite I've newer build PostgreSQL
> on Windows (I definitely should try). If i have problems then I will ask
> you for binary.

Great, please try the attached trivial patch.

//Magnus
Index: src/backend/port/win32_sema.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/port/win32_sema.c,v
retrieving revision 1.4
diff -c -r1.4 win32_sema.c
*** src/backend/port/win32_sema.c    5 Jan 2007 22:19:35 -0000    1.4
--- src/backend/port/win32_sema.c    22 Apr 2007 18:19:13 -0000
***************
*** 82,88 ****
      sec_attrs.bInheritHandle = TRUE;

      /* We don't need a named semaphore */
!     cur_handle = CreateSemaphore(&sec_attrs, 1, 1, NULL);
      if (cur_handle)
      {
          /* Successfully done */
--- 82,88 ----
      sec_attrs.bInheritHandle = TRUE;

      /* We don't need a named semaphore */
!     cur_handle = CreateSemaphore(&sec_attrs, 1, 32767, NULL);
      if (cur_handle)
      {
          /* Successfully done */

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [Fwd: PGBuildfarm member narwhal Branch HEAD Status changed from OK to InstallCheck failure]
Следующее
От: "Marko Kreen"
Дата:
Сообщение: contrib/uuid-ossp: immutable vs. volatile