Re: Way to check whether a particular block is on the shared_buffer?

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: Way to check whether a particular block is on the shared_buffer?
Дата
Msg-id 56B3E9DE.6090802@BlueTreble.com
обсуждение исходный текст
Ответ на Re: Way to check whether a particular block is on the shared_buffer?  (Kouhei Kaigai <kaigai@ak.jp.nec.com>)
Ответы Re: Way to check whether a particular block is on the shared_buffer?  (Kouhei Kaigai <kaigai@ak.jp.nec.com>)
Re: Way to check whether a particular block is on the shared_buffer?  (Kouhei Kaigai <kaigai@ak.jp.nec.com>)
Список pgsql-hackers
On 2/4/16 12:30 AM, Kouhei Kaigai wrote:
>> 2. A feature to suspend i/o write-out towards a particular blocks
>> >    that are registered by other concurrent backend, unless it is not
>> >    unregistered (usually, at the end of P2P DMA).
>> >    ==> to be discussed.

I think there's still a race condition here though...

A
finds buffer not in shared buffers

B
reads buffer in
modifies buffer
starts writing buffer to OS

A
Makes call to block write, but write is already in process; thinks
writes are now blocked
Reads corrupted block
Much hilarity ensues

Or maybe you were just glossing over that part for brevity.

...

> I tried to design a draft of enhancement to realize the above i/o write-out
> suspend/resume, with less invasive way as possible as we can.
> 
>    ASSUMPTION: I intend to implement this feature as a part of extension,
>        because this i/o suspend/resume checks are pure overhead increment
>        for the core features, unless extension which utilizes it.
> 
> Three functions shall be added:
> 
> extern int    GetStorageMgrNumbers(void);
> extern f_smgr GetStorageMgrHandlers(int smgr_which);
> extern void   SetStorageMgrHandlers(int smgr_which, f_smgr smgr_handlers);
> 
> As literal, GetStorageMgrNumbers() returns the number of storage manager
> currently installed. It always return 1 right now.
> GetStorageMgrHandlers() returns the currently configured f_smgr table to
> the supplied smgr_which. It allows extensions to know current configuration
> of the storage manager, even if other extension already modified it.
> SetStorageMgrHandlers() assigns the supplied 'smgr_handlers', instead of
> the current one.
> If extension wants to intermediate 'smgr_write', extension will replace
> the 'smgr_write' by own function, then call the original function, likely
> mdwrite, from the alternative function.
> 
> In this case, call chain shall be:
> 
>    FlushBuffer, and others...
>     +-- smgrwrite(...)
>          +-- (extension's own function)
>               +-- mdwrite

ISTR someone (Robert Haas?) complaining that this method of hooks is
cumbersome to use and can be fragile if multiple hooks are being
installed. So maybe we don't want to extend it's usage...

I'm also not sure whether this is better done with an smgr hook or a
hook into shared buffer handling...
-- 
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com



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

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: proposal: PL/Pythonu - function ereport
Следующее
От: Jim Nasby
Дата:
Сообщение: Re: Batch update of indexes