Re: [HACKERS] Is pg_control file crashsafe?

2016-05-06 Thread Alex Ignatov
On 05.05.2016 7:16, Amit Kapila wrote: On Wed, May 4, 2016 at 8:03 PM, Tom Lane mailto:t...@sss.pgh.pa.us>> wrote: > > Amit Kapila mailto:amit.kapil...@gmail.com>> writes: > > On Wed, May 4, 2016 at 4:02 PM, Alex Ignatov mailto:a.igna...@postgrespro.ru>> > > wrote: > >> On 03.05.2016 2:17,

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-06 Thread Alex Ignatov
On 06.05.2016 0:42, Greg Stark wrote: On 5 May 2016 12:32 am, "Tom Lane" mailto:t...@sss.pgh.pa.us>> wrote: > > To repeat, I'm pretty hesitant to change this logic. While this is not > the first report we've ever heard of loss of pg_control, I believe I could > count those reports without r

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-05 Thread Tom Lane
Greg Stark writes: > One thing we could do without much worry of being less reliable would be to > keep two copies of pg_control. Write one, fsync, then write to the other > and fsync that one. Hmm, interesting thought. Without knowing more about the filesystem problem that the OP had, it's hard

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-05 Thread Greg Stark
On 5 May 2016 12:32 am, "Tom Lane" wrote: > > To repeat, I'm pretty hesitant to change this logic. While this is not > the first report we've ever heard of loss of pg_control, I believe I could > count those reports without running out of fingers on one hand --- and > that's counting since the la

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-05 Thread Andres Freund
On 2016-05-05 00:32:29 -0400, Tom Lane wrote: > To repeat, I'm pretty hesitant to change this logic. While this is not > the first report we've ever heard of loss of pg_control, I believe I could > count those reports without running out of fingers on one hand --- and > that's counting since the l

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-05 Thread Amit Kapila
On Thu, May 5, 2016 at 11:52 AM, Thomas Munro wrote: > > On Thu, May 5, 2016 at 4:32 PM, Tom Lane wrote: > > Amit Kapila writes: > >> How about using 512 bytes as a write size and perform direct writes rather > >> than going via OS buffer cache for control file? > > > > Wouldn't that fail outrig

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-04 Thread Thomas Munro
On Thu, May 5, 2016 at 4:32 PM, Tom Lane wrote: > Amit Kapila writes: >> How about using 512 bytes as a write size and perform direct writes rather >> than going via OS buffer cache for control file? > > Wouldn't that fail outright under a lot of implementations of direct write; > ie the request

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-04 Thread Tom Lane
Amit Kapila writes: > How about using 512 bytes as a write size and perform direct writes rather > than going via OS buffer cache for control file? Wouldn't that fail outright under a lot of implementations of direct write; ie the request needs to be page-aligned, for some not-very-determinate va

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-04 Thread Amit Kapila
On Wed, May 4, 2016 at 8:03 PM, Tom Lane wrote: > > Amit Kapila writes: > > On Wed, May 4, 2016 at 4:02 PM, Alex Ignatov > > wrote: > >> On 03.05.2016 2:17, Tom Lane wrote: > >>> Writing a single sector ought to be atomic too. > > >> pg_control is 8k long(i think it is legth of one page in defau

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-04 Thread Tom Lane
Amit Kapila writes: > On Wed, May 4, 2016 at 4:02 PM, Alex Ignatov > wrote: >> On 03.05.2016 2:17, Tom Lane wrote: >>> Writing a single sector ought to be atomic too. >> pg_control is 8k long(i think it is legth of one page in default PG >> compile settings). > The actual data written is always

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-04 Thread Amit Kapila
On Wed, May 4, 2016 at 4:02 PM, Alex Ignatov wrote: > > > On 03.05.2016 2:17, Tom Lane wrote: > >> Alex Ignatov writes: >> >>> I think that rename can help a little bit. At least on some FS it is >>> atomic operation. >>> >> >> Writing a single sector ought to be atomic too. I'm very skeptical

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-04 Thread Alex Ignatov
On 03.05.2016 2:17, Tom Lane wrote: Alex Ignatov writes: I think that rename can help a little bit. At least on some FS it is atomic operation. Writing a single sector ought to be atomic too. I'm very skeptical that it'll be an improvement to just move the risk from one filesystem operatio

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-04 Thread Alex Ignatov
Alex Ignatov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company On 03.05.2016 2:21, Andres Freund wrote: Hi, On 2016-04-28 21:58:00 +, Alex Ignatov wrote: We have some issue with truncated pg_control file on Windows after power failure.My questions is : 1) Is

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-02 Thread Andres Freund
Hi, On 2016-04-28 21:58:00 +, Alex Ignatov wrote: > We have some issue with truncated pg_control file on Windows after > power failure.My questions is : 1) Is pg_control protected from say , > power crash or partial write? It should be. I think to make progress on this thread we're going to n

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-02 Thread Tom Lane
Alex Ignatov writes: > I think that rename can help a little bit. At least on some FS it is > atomic operation. Writing a single sector ought to be atomic too. I'm very skeptical that it'll be an improvement to just move the risk from one filesystem operation to another; especially not to one w

Re: [HACKERS] Is pg_control file crashsafe?

2016-05-02 Thread Alex Ignatov
On 01.05.2016 0:55, Bruce Momjian wrote: On Thu, Apr 28, 2016 at 09:58:00PM +, Alex Ignatov wrote: Hello everyone! We have some issue with truncated pg_control file on Windows after power failure. My questions is : 1) Is pg_control protected from say , power crash or partial write? 2) How

Re: [HACKERS] Is pg_control file crashsafe?

2016-04-30 Thread Bruce Momjian
On Thu, Apr 28, 2016 at 09:58:00PM +, Alex Ignatov wrote: > Hello everyone! > We have some issue with truncated pg_control file on Windows after power > failure. > My questions is : > 1) Is pg_control protected from say , power crash or partial write? > 2) How PG update pg_control? By writing