Re: xlog.c: WALInsertLock vs. WALWriteLock

Поиск
Список
Период
Сортировка
От Tallat Mahmood
Тема Re: xlog.c: WALInsertLock vs. WALWriteLock
Дата
Msg-id AANLkTimPejdzScjxq9rJ8C4kLB_YVhmnO+gsAmUnMNwK@mail.gmail.com
обсуждение исходный текст
Ответ на Re: xlog.c: WALInsertLock vs. WALWriteLock  (David Fetter <david@fetter.org>)
Список pgsql-hackers
> I'm writing a function that will read data from the buffer in xlog
> (i.e.  from XLogCtl->pages and XLogCtl->xlblocks).  I want to make
> sure that I am doing it correctly.

Got an example of what the function might look like?

Say something like this:
bool ReadLogFromBuffer(char *buf, int len, XLogRecPtr p) 
which will mean that we want to read the log (records) into buf at position p of length len.
 

> For reading from the buffer, do I need to lock WALInsertLock or
> WALWriteLock?  Also, can you explain a bit the usage of 'LW_SHARED'.
> Can we use it for read purposes?

Help me understand.  Do you foresee some kind of concurrency issue,
and if so, what?

Yes. For example, while a process is reading from the buffer, another process may insert new records into the buffer. To give a specific example, walsender might want to read data from the buffer instead of reading log from disk. In parallel, there might be transactions on the server that modify the buffer.

Regards,
Tallat



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: ask for review of MERGE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: WIP: extensible enums