On Thu, Aug 25, 2016 at 1:13 PM, Robert Haas <robertmh...@gmail.com> wrote:
> On Thu, Aug 25, 2016 at 10:25 AM, Yury Zhuravlev
> <u.zhurav...@postgrespro.ru> wrote:
>> I have a small question. While working on an incremental backup I noticed a
>> strange thing.
>> Newly created index is contains the invalid LSN (0/0).
>> Exmaple:
>> postgres=# select lsn from page_header(get_raw_page('test_a_idx2',0));
>> lsn -----
>> 0/0
>> (1 row)
>> Can you explain me why?
> Why not?

Hmm, maybe I can do better than that.  In general, the reason why we
set the page LSN is to prevent the page from being written before the
WAL record that most recently modified it is flushed to disk; this is
a necessary invariant of write-ahead logging.  But for an index build
we don't need to generate any WAL records: if the system crashes, the
entire transaction will be considered to have aborted and the
relfilenode in which the new index was being written will be ignored,
so it doesn't matter whether we recover any of the contents of that
file.  Since there's no WAL being generated, there's no need to set
LSNs on the pages.

Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to