Re: PATCH: pg_restore parallel-execution-deadlock issue

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: PATCH: pg_restore parallel-execution-deadlock issue
Дата
Msg-id CAB7nPqQSVN4xUoaZ7N-oMCc-0j0+UQ5j4DirV-BU3TyufKCrWw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PATCH: pg_restore parallel-execution-deadlock issue  (Amit Kapila <amit.kapila16@gmail.com>)
Ответы Re: PATCH: pg_restore parallel-execution-deadlock issue  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Fri, May 27, 2016 at 4:07 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> On Fri, May 27, 2016 at 3:05 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>> Michael Paquier <michael.paquier@gmail.com> writes:
>> > ea274b2 has changed the way disconnection is done is is now closing
>> > both the read and write pipes. So you may want to retry if things get
>> > better with the next round of minor releases.
>>
>> Hadn't paid attention to this thread before ...
>>
>> 1. Armin proposes using "shutdown(pipeWrite, SD_BOTH)" where the code
>> committed this morning (df8d2d8c4) has "closesocket(pipeWrite)".
>> I'd prefer to leave it that way since it's the same as for the Unix case,
>> and Kyotaro-san says it works for him.  Is there a reason we'd need
>> shutdown() instead?

Hm, OK.

>> 2. Armin proposes that WaitForTerminatingWorkers needs to do CloseHandle()
>> on the various thread handles.  That sounds plausible but I don't know
>> enough Windows programming to know if it really matters.
>>
>> 3. Should we replace ExitThread() with _endthreadex()?  Again, it
>> seems plausible but I'm not the person to ask.
>>
>
> I think point (2) and (3) are related because using _endthreadex won't close
> the thread handle explicitly [1].

Yep.

> [1] - https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx
> Refer line "_endthread automatically closes the thread handle, whereas
> _endthreadex does not."

And the rest of the sentence:
Therefore, when you use _beginthread and _endthread, do not explicitly
close the thread handle by calling the Win32 CloseHandle API. This
behavior differs from the Win32 ExitThread API.

Personally I understand that as well as for the first part: when using
_beginthreadex and _endthreadex, be sure to call CloseHandle() to
explicitely close the thread handle.

And based on the second part if we use ExitThread after beginning a
thread with _beginthreadex we would get unreliable behavior. I guess
you don't need a patch? Because by looking again at this thread and
the windows docs what we have now is unpredictable.
-- 
Michael



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

Предыдущее
От: Léonard Benedetti
Дата:
Сообщение: Fix a typo in 9.6 release notes
Следующее
От: Nikolay Shaplov
Дата:
Сообщение: Re: [PROPOSAL] Move all am-related reloption code into src/backend/access/[am-name] and get rid of relopt_kind