[COMMITTERS] pgsql: Properly initialize write, flush and replay locations in walsend

2015-12-13 Thread Magnus Hagander
Properly initialize write, flush and replay locations in walsender slots

These would leak random xlog positions if a walsender used for backup would
a walsender slot previously used by a replication walsender.

In passing also fix a couple of cases where the xlog pointer is directly
compared to zero instead of using XLogRecPtrIsInvalid, noted by
Michael Paquier.

Branch
--
REL9_5_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/a9c56ff0e1f19fd6c2e48cfe44407c8cb8c4fbd5

Modified Files
--
src/backend/replication/walsender.c |9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Properly initialize write, flush and replay locations in walsend

2015-12-13 Thread Magnus Hagander
Properly initialize write, flush and replay locations in walsender slots

These would leak random xlog positions if a walsender used for backup would
a walsender slot previously used by a replication walsender.

In passing also fix a couple of cases where the xlog pointer is directly
compared to zero instead of using XLogRecPtrIsInvalid, noted by
Michael Paquier.

Branch
--
master

Details
---
http://git.postgresql.org/pg/commitdiff/263c19572bd4947b4cf977d61db11b74b1745570

Modified Files
--
src/backend/replication/walsender.c |9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Consistently set all fields in pg_stat_replication to null inste

2015-12-13 Thread Magnus Hagander
Consistently set all fields in pg_stat_replication to null instead of 0

Previously the "sent" field would be set to 0 and all other xlog
pointers be set to NULL if there were no valid values (such as when
in a backup sending walsender).

Branch
--
master

Details
---
http://git.postgresql.org/pg/commitdiff/a91bdf67c49ade2bdf6474607b64f9f0083db4a6

Modified Files
--
src/backend/replication/walsender.c |3 +++
1 file changed, 3 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Properly initialize write, flush and replay locations in walsend

2015-12-13 Thread Magnus Hagander
Properly initialize write, flush and replay locations in walsender slots

These would leak random xlog positions if a walsender used for backup would
a walsender slot previously used by a replication walsender.

In passing also fix a couple of cases where the xlog pointer is directly
compared to zero instead of using XLogRecPtrIsInvalid, noted by
Michael Paquier.

Branch
--
REL9_3_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/a1fb84990dc172f21f12a8fb79ab58876e81fe6b

Modified Files
--
src/backend/replication/walsender.c |9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Properly initialize write, flush and replay locations in walsend

2015-12-13 Thread Magnus Hagander
Properly initialize write, flush and replay locations in walsender slots

These would leak random xlog positions if a walsender used for backup would
a walsender slot previously used by a replication walsender.

In passing also fix a couple of cases where the xlog pointer is directly
compared to zero instead of using XLogRecPtrIsInvalid, noted by
Michael Paquier.

Branch
--
REL9_4_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/61c7bee2196d284a19692d83b33eac7588693292

Modified Files
--
src/backend/replication/walsender.c |9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Consistently set all fields in pg_stat_replication to null inste

2015-12-13 Thread Magnus Hagander
Consistently set all fields in pg_stat_replication to null instead of 0

Previously the "sent" field would be set to 0 and all other xlog
pointers be set to NULL if there were no valid values (such as when
in a backup sending walsender).

Branch
--
REL9_5_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/28c366789e78af82dfd89ecb6cc32724f58d6a1b

Modified Files
--
src/backend/replication/walsender.c |3 +++
1 file changed, 3 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Fix bug leading to restoring unlogged relations from empty files

2015-12-13 Thread Andres Freund
On 2015-12-13 12:37:18 -0500, Tom Lane wrote:
> Andres Freund  writes:
> > Fix bug leading to restoring unlogged relations from empty files.
> 
> Coverity thinks, quite correctly AFAICS, that this line you wrote in
> FlushOneBuffer() is useless:
> 
>   LWLockHeldByMe(bufHdr->content_lock);
> 
> Perhaps you meant
> 
>   Assert(LWLockHeldByMe(bufHdr->content_lock));
> 

Yes :(. I'll be back at my computer in a couple hours and will fix it
then or tomorrow morning.

Andres


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Fix bug leading to restoring unlogged relations from empty files

2015-12-13 Thread Tom Lane
Andres Freund  writes:
> Fix bug leading to restoring unlogged relations from empty files.

Coverity thinks, quite correctly AFAICS, that this line you wrote in
FlushOneBuffer() is useless:

LWLockHeldByMe(bufHdr->content_lock);

Perhaps you meant

Assert(LWLockHeldByMe(bufHdr->content_lock));

?

regards, tom lane


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Code and docs review for multiple -c and -f options in psql.

2015-12-13 Thread Tom Lane
Code and docs review for multiple -c and -f options in psql.

Commit d5563d7df94488bf drew complaints from Coverity, which quite
correctly complained that one copy of each -c or -f string was being
leaked.  What's more, simple_action_list_append was allocating enough space
for still a third copy of each string as part of the SimpleActionListCell,
even though that coding method had been superseded by a separate strdup
operation.  There were some other minor coding infelicities too.  The
documentation needed more work as well, eg it forgot to explain that -c
causes psql not to accept any interactive input.

Branch
--
master

Details
---
http://git.postgresql.org/pg/commitdiff/fcbbf82d2b6caf7b156f2ec35b322e23caf1e99e

Modified Files
--
doc/src/sgml/ref/psql-ref.sgml |  140 +++-
src/bin/psql/startup.c |   93 --
2 files changed, 121 insertions(+), 112 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Fix bug leading to restoring unlogged relations from empty files

2015-12-13 Thread Peter Eisentraut
Coverity is complaining that in

void
FlushOneBuffer(Buffer buffer)
{
BufferDesc *bufHdr;

/* currently not needed, but no fundamental reason not to support */
Assert(!BufferIsLocal(buffer));

Assert(BufferIsPinned(buffer));

bufHdr = GetBufferDescriptor(buffer - 1);

LWLockHeldByMe(bufHdr->content_lock);

FlushBuffer(bufHdr, NULL);
}

the call to LWLockHeldByMe() is useless.


On 12/10/15 10:50 AM, Andres Freund wrote:
> Fix bug leading to restoring unlogged relations from empty files.
> 
> At the end of crash recovery, unlogged relations are reset to the empty
> state, using their init fork as the template. The init fork is copied to
> the main fork without going through shared buffers. Unfortunately WAL
> replay so far has not necessarily flushed writes from shared buffers to
> disk at that point. In normal crash recovery, and before the
> introduction of 'fast promotions' in fd4ced523 / 9.3, the
> END_OF_RECOVERY checkpoint flushes the buffers out in time. But with
> fast promotions that's not the case anymore.
> 
> To fix, force WAL writes targeting the init fork to be flushed
> immediately (using the new FlushOneBuffer() function). In 9.5+ that
> flush can centrally be triggered from the code dealing with restoring
> full page writes (XLogReadBufferForRedoExtended), in earlier releases
> that responsibility is in the hands of XLOG_HEAP_NEWPAGE's replay
> function.
> 
> Backpatch to 9.1, even if this currently is only known to trigger in
> 9.3+. Flushing earlier is more robust, and it is advantageous to keep
> the branches similar.
> 
> Typical symptoms of this bug are errors like
> 'ERROR:  index "..." contains unexpected zero page at block 0'
> shortly after promoting a node.
> 
> Reported-By: Thom Brown
> Author: Andres Freund and Michael Paquier
> Discussion: 20150326175024.gj...@alap3.anarazel.de
> Backpatch: 9.1-
> 
> Branch
> --
> REL9_5_STABLE
> 
> Details
> ---
> http://git.postgresql.org/pg/commitdiff/5b51805fe4b9fec95274924c5733093a5f685a58
> 
> Modified Files
> --
> src/backend/access/transam/xlogutils.c |9 +
> src/backend/storage/buffer/bufmgr.c|   21 +
> src/include/storage/bufmgr.h   |1 +
> 3 files changed, 31 insertions(+)
> 
> 



-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Code and docs review for multiple -c and -f options in psql.

2015-12-13 Thread Michael Paquier
On Mon, Dec 14, 2015 at 11:16 AM, Michael Paquier wrote:
> -   cell = (SimpleActionListCell *)
> -   pg_malloc(offsetof(SimpleActionListCell, val) + vallen + 1);
> Thanks! Among all those things this bit is a bit shameful..

(I am the one at the origin of that FWIW)
-- 
Michael


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Code and docs review for multiple -c and -f options in psql.

2015-12-13 Thread Michael Paquier
On Mon, Dec 14, 2015 at 4:52 AM, Tom Lane  wrote:
> Code and docs review for multiple -c and -f options in psql.
>
> Commit d5563d7df94488bf drew complaints from Coverity, which quite
> correctly complained that one copy of each -c or -f string was being
> leaked.  What's more, simple_action_list_append was allocating enough space
> for still a third copy of each string as part of the SimpleActionListCell,
> even though that coding method had been superseded by a separate strdup
> operation.  There were some other minor coding infelicities too.  The
> documentation needed more work as well, eg it forgot to explain that -c
> causes psql not to accept any interactive input.

-   cell = (SimpleActionListCell *)
-   pg_malloc(offsetof(SimpleActionListCell, val) + vallen + 1);
Thanks! Among all those things this bit is a bit shameful..
-- 
Michael


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Docs: document that psql's "\i -" means read from stdin.

2015-12-13 Thread Tom Lane
Docs: document that psql's "\i -" means read from stdin.

This has worked that way for a long time, maybe always, but you would
not have known it from the documentation.  Also back-patch the notes
I added to HEAD earlier today about behavior of the "-f -" switch,
which likewise have been valid for many releases.

Branch
--
REL9_1_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/20f85bc50beae343d921e4992dcadce80b09c404

Modified Files
--
doc/src/sgml/ref/psql-ref.sgml |   12 +++-
1 file changed, 11 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Docs: document that psql's "\i -" means read from stdin.

2015-12-13 Thread Tom Lane
Docs: document that psql's "\i -" means read from stdin.

This has worked that way for a long time, maybe always, but you would
not have known it from the documentation.  Also back-patch the notes
I added to HEAD earlier today about behavior of the "-f -" switch,
which likewise have been valid for many releases.

Branch
--
REL9_3_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/818a680a6f0bc565cc12aaf9fa67752988b40f21

Modified Files
--
doc/src/sgml/ref/psql-ref.sgml |   12 +++-
1 file changed, 11 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Docs: document that psql's "\i -" means read from stdin.

2015-12-13 Thread Tom Lane
Docs: document that psql's "\i -" means read from stdin.

This has worked that way for a long time, maybe always, but you would
not have known it from the documentation.  Also back-patch the notes
I added to HEAD earlier today about behavior of the "-f -" switch,
which likewise have been valid for many releases.

Branch
--
REL9_2_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/6436445e9f311bc833d052c0fc39055fcbe09276

Modified Files
--
doc/src/sgml/ref/psql-ref.sgml |   12 +++-
1 file changed, 11 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Docs: document that psql's "\i -" means read from stdin.

2015-12-13 Thread Tom Lane
Docs: document that psql's "\i -" means read from stdin.

This has worked that way for a long time, maybe always, but you would
not have known it from the documentation.  Also back-patch the notes
I added to HEAD earlier today about behavior of the "-f -" switch,
which likewise have been valid for many releases.

Branch
--
master

Details
---
http://git.postgresql.org/pg/commitdiff/7bd149ce2aa6af8910604eb45cc202798f563781

Modified Files
--
doc/src/sgml/ref/psql-ref.sgml |7 +++
1 file changed, 7 insertions(+)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Docs: document that psql's "\i -" means read from stdin.

2015-12-13 Thread Tom Lane
Docs: document that psql's "\i -" means read from stdin.

This has worked that way for a long time, maybe always, but you would
not have known it from the documentation.  Also back-patch the notes
I added to HEAD earlier today about behavior of the "-f -" switch,
which likewise have been valid for many releases.

Branch
--
REL9_4_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/38a4a42197f2b9fd237fc9b3958e602f25ffcd30

Modified Files
--
doc/src/sgml/ref/psql-ref.sgml |   12 +++-
1 file changed, 11 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


[COMMITTERS] pgsql: Docs: document that psql's "\i -" means read from stdin.

2015-12-13 Thread Tom Lane
Docs: document that psql's "\i -" means read from stdin.

This has worked that way for a long time, maybe always, but you would
not have known it from the documentation.  Also back-patch the notes
I added to HEAD earlier today about behavior of the "-f -" switch,
which likewise have been valid for many releases.

Branch
--
REL9_5_STABLE

Details
---
http://git.postgresql.org/pg/commitdiff/c9ed438817661238901f43ea10aab8f120ea837f

Modified Files
--
doc/src/sgml/ref/psql-ref.sgml |   12 +++-
1 file changed, 11 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Fix bug leading to restoring unlogged relations from empty files

2015-12-13 Thread Michael Paquier
On Mon, Dec 14, 2015 at 2:26 PM, Peter Eisentraut  wrote:
> the call to LWLockHeldByMe() is useless.

Yes, but it should be an Assert. I guess that Andres is on it..
-- 
Michael


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Re: [COMMITTERS] pgsql: Code and docs review for multiple -c and -f options in psql.

2015-12-13 Thread Pavel Stehule
2015-12-14 3:16 GMT+01:00 Michael Paquier :

> On Mon, Dec 14, 2015 at 11:16 AM, Michael Paquier wrote:
> > -   cell = (SimpleActionListCell *)
> > -   pg_malloc(offsetof(SimpleActionListCell, val) + vallen + 1);
> > Thanks! Among all those things this bit is a bit shameful..
>
> (I am the one at the origin of that FWIW)
>

me too

Thank you

Pavel


> --
> Michael
>
>
> --
> Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-committers
>