> 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

Reply via email to