Re: .ready and .done files considered harmful
Nathan Bossart <bossartn@amazon.com>
From: "Bossart, Nathan" <bossartn@amazon.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Dipesh Pandit <dipesh.pandit@gmail.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, Jeevan Ladhe <jeevan.ladhe@enterprisedb.com>, Stephen Frost <sfrost@snowman.net>, Andres Freund <andres@anarazel.de>, Hannu
Krosing <hannuk@google.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2021-08-17T19:09:07Z
Lists: pgsql-hackers
On 8/17/21, 11:28 AM, "Robert Haas" <robertmhaas@gmail.com> wrote: > I can't actually see that there's any kind of hard synchronization > requirement here at all. What we're trying to do is guarantee that if > the timeline changes, we'll pick up the timeline history for the new > timeline next, and that if files are archived out of order, we'll > switch to archiving the oldest file that is now present rather than > continuing with consecutive files. But suppose we just use an > unsynchronized bool. The worst case is that we'll archive one extra > file proceeding in order before we jump to the file that we were > supposed to archive next. It's not evident to me that this is all that > bad. The same thing would have happened if the previous file had been > archived slightly faster than it actually was, so that we began > archiving the next file just before, rather than just after, the > notification was sent. And if it is bad, wrapping an LWLock around the > accesses to the flag variable, or using an atomic, does nothing to > stop it. I am inclined to agree. The archiver only ever reads the flag and sets it to false (if we are doing a directory scan). Others only ever set the flag to true. The only case I can think of where we might miss the timeline switch or out-of-order .ready file is when the archiver sets the flag to false and then ReadDir() fails. However, that seems to cause the archiver process to restart, and we always start with a directory scan at first. Nathan
Commits
-
Reduce overhead of renaming archive status files.
- 756e221db610 16.0 cited
-
Improve performance of pgarch_readyXlog() with many status files.
- beb4e9ba1652 15.0 landed
-
Prioritize history files when archiving
- b981df4cc09a 12.0 cited