Re: pg_basebackup stream xlog to tar - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: pg_basebackup stream xlog to tar
Date
Msg-id CAB7nPqRuo5_jYVP0LVnGVgOjRN5h2tbiNkrh0QGczpECyLsHBA@mail.gmail.com
Whole thread Raw
In response to Re: pg_basebackup stream xlog to tar  (Magnus Hagander <magnus@hagander.net>)
Responses Re: pg_basebackup stream xlog to tar
List pgsql-hackers
On Sun, Oct 23, 2016 at 10:28 PM, Magnus Hagander <magnus@hagander.net> wrote:
> It also broke the tests and invalidated some documentation. But it was easy
> enough to fix.
>
> I've now applied this, so next time you get to do the merging :P Joking
> aside, please review and let me know if you can spot something I messed up
> in the final merge.

Just had another look at it..
+static int
+tar_fsync(Walfile f)
+{
+   Assert(f != NULL);
+   tar_clear_error();
+
+   /*
+    * Always sync the whole tarfile, because that's all we can do. This makes
+    * no sense on compressed files, so just ignore those.
+    */
+   if (tar_data->compression)
+       return 0;
+
+   return fsync(tar_data->fd);
+}
fsync() should not be called here if --no-sync is used.

+   /* sync the empty blocks as well, since they're after the last file */
+   fsync(tar_data->fd);
Similarly, the fsync call of tar_finish() should not happen when
--no-sync is used.

+   if (format == 'p')
+       stream.walmethod = CreateWalDirectoryMethod(param->xlog, do_sync);
+   else
+       stream.walmethod = CreateWalTarMethod(param->xlog,
compresslevel, do_sync);
LogStreamerMain() exits immediately once it is done, but I think that
we had better be tidy here and clean up the WAL methods that have been
allocated. I am thinking here about a potentially retry method on
failure, though the best shot in this area would be with
ReceiveXlogStream().

Attached is a patch addressing those points.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: issue with track_commit_timestamp and server restart
Next
From: Rushabh Lathia
Date:
Subject: Re: Gather Merge