From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Thom Brown <thom(at)linux(dot)com>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, Fabrízio Mello <fabriziomello(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Error with index on unlogged table |
Date: | 2015-12-08 12:57:16 |
Message-ID: | 20151208125716.GS4934@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2015-12-03 22:09:43 +0100, Andres Freund wrote:
> On 2015-11-20 16:11:15 +0900, Michael Paquier wrote:
> > + if (bkpb.fork == INIT_FORKNUM)
> > + {
> > + SMgrRelation srel;
> > + srel = smgropen(bkpb.node, InvalidBackendId);
> > + smgrimmedsync(srel, INIT_FORKNUM);
> > + smgrclose(srel);
> > + }
>
> A smgrwrite() instead of a smgrimmedsync() should be sufficient here.
More importantly, the smgrimmedsync() won't actually achieve anything -
RestoreBackupBlockContents() will just have written the data into shared
buffers. smgrimmedsync() doesn't flush that.
And further, just flushing the buffer directly to disk using
smgrwrite(), without reflecting that in the in-memory state, doesn't
seem prudent. At the very least we'll write all those blocks twice. It
also likely misses dealing with checksums and such.
What I think we really ought to do instead is to use "proper" buffer
functionality, e.g. flush the buffer via FlushBuffer().
It seems slightly better not to directly expose FlushBuffer() and
instead add a tiny wrapper. Couldn't come up with a grand name tho.
For me the attached, preliminary, patch, fixes the problem in master;
previous branches ought to look mostly similar, except the flush moved
to RestoreBackupBlockContents/RestoreBackupBlock.
Does anybody have a better idea? Suitable for the back-branches?
I'm kinda wondering if it wouldn't have been better to go through shared
buffers in ResetUnloggedRelationsInDbspaceDir() instead of using
copy_file().
Regareds,
Andres
Attachment | Content-Type | Size |
---|---|---|
0001-Preliminary-unlogged-rel-recovery-fix.patch | text/x-patch | 2.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2015-12-08 13:09:54 | Re: Error with index on unlogged table |
Previous Message | Sandeep Thakkar | 2015-12-08 12:27:08 | Include ppc64le build type for back branches |