Re: xlog.c: WALInsertLock vs. WALWriteLock - Mailing list pgsql-hackers

From Tallat Mahmood
Subject Re: xlog.c: WALInsertLock vs. WALWriteLock
Date
Msg-id AANLkTimPejdzScjxq9rJ8C4kLB_YVhmnO+gsAmUnMNwK@mail.gmail.com
Whole thread Raw
In response to Re: xlog.c: WALInsertLock vs. WALWriteLock  (David Fetter <david@fetter.org>)
List 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 by date:

Previous
From: Robert Haas
Date:
Subject: Re: ask for review of MERGE
Next
From: Tom Lane
Date:
Subject: Re: WIP: extensible enums