Re: Attempt to consolidate reading of XLOG page
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Antonin Houska <ah@cybertec.at>, Thomas Munro <thomas.munro@gmail.com>, Robert Haas <robertmhaas@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2019-11-20T08:38:02Z
Lists: pgsql-hackers
On Mon, Nov 18, 2019 at 09:29:03PM +0900, Michael Paquier wrote: > Now, read() > pread() > read()+lseek(), and we don't actually need to > seek into the file for all the cases where we read a WAL page. And on > a platform which uses the fallback implementation, this increases the > number of lseek() calls. I can see as you say that using it directly > in the refactoring can simplify the code. Putting this point aside, here is the error coming from contrib/test_decoding/, and this is independent of Alvaro's changes: +ERROR: invalid magic number 0000 in log segment 000000010000000000000001, offset 6905856 I don't think that this is just xlp_magic messed up, the full page read is full of zeros. But that's just a guess. Looking at the code, I am spotting one inconsistency in the way seg->ws_off is compiled after doing the read on the new version compared to the three others. read() would move the offset of the file, but the code is forgetting to increment it by a amount of readbytes. Isn't that incorrect? A second thing is that wal_segment_open() definition is incorrect in xlogutils.c, generating a warning. The opened fd is the returned result, and not an argument of the routine. I am switching the patch as waiting on author. Antonin, could you look at those problems? -- Michael
Commits
-
Remove logical_read_local_xlog_page
- 5d0c2d5eba6b 13.0 landed
-
Refactor WAL file-reading code into WALRead()
- 0dc8ead46363 13.0 landed
-
Rework WAL-reading supporting structs
- 709d003fbd98 13.0 landed
-
Make XLogReaderInvalReadState static
- 25dcc9d35dfe 13.0 landed
-
Use pg_pread() and pg_pwrite() for data files and WAL.
- c24dcd0cfd94 12.0 cited