Re: Deadlock detection

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: Deadlock detection
Дата
Msg-id 4976FD97.7040609@opencloud.com
обсуждение исходный текст
Ответ на Re: Deadlock detection  (Oliver Jowett <oliver@opencloud.com>)
Список pgsql-jdbc
Oliver Jowett wrote:

> If you want a minimally invasive approach (in terms of rewriting driver
> code) and some extra overhead isn't a problem then I would suggest
> something like this:
>
> (1) spawn a separate write thread for each connection; it reads from an
> unbounded buffer
>
> (2)instead of writes from the thread running a query going directly to
> the real stream, they instead go into the buffer (without blocking), and
> the corresponding write thread picks them up for immediate writing
>
> (3) implement OutputStream.flush() to wait for the buffer to empty,
> *with a timeout*. If you hit the timeout while waiting to flush, then
> you've detected a potential deadlock case and can dump out some state
> and then continue anyway.

Also, if it wasn't obvious, I'm thinking you do this by a custom
OutputStream implementation that just sits on top of the real stream;
you don't need to change any of the callers so it's just a bit of setup
code then the vast majority of the driver guts are unchanged. You could
even make it conditional on a connection parameter ..

-O


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

Предыдущее
От: Oliver Jowett
Дата:
Сообщение: Re: Deadlock detection
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: Deadlock detection