pg_receivexlog and replication slots

Started by Magnus Haganderalmost 12 years ago56 messageshackers
Jump to latest
#1Magnus Hagander
magnus@hagander.net

Is there a particular reason why pg_receivexlog only supports using
manually created slots but pg_recvlogical supports creating and
dropping them? Wouldn't it be good for consistency there?

I'm guessing it's related to not being exposed over the replication
protocol? We had a discussion earlier that I remember about being able
to use an "auto-drop" slot in pg_basebackup, but this would be
different - this would be about creating and dropping a regular
physical replication slot...

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

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

#2Andres Freund
andres@anarazel.de
In reply to: Magnus Hagander (#1)
Re: pg_receivexlog and replication slots

On 2014-07-11 11:08:48 +0200, Magnus Hagander wrote:

Is there a particular reason why pg_receivexlog only supports using
manually created slots but pg_recvlogical supports creating and
dropping them? Wouldn't it be good for consistency there?

I've added it to recvlogical because logical decoding isn't usable
without slots. I'm not sure what you'd want to create/drop a slot from
receivexlog for, but I'm not adverse to adding the capability.

I'm guessing it's related to not being exposed over the replication
protocol?

It's exposed:
create_replication_slot:
/* CREATE_REPLICATION_SLOT slot PHYSICAL */
K_CREATE_REPLICATION_SLOT IDENT K_PHYSICAL

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

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

#3Magnus Hagander
magnus@hagander.net
In reply to: Andres Freund (#2)
Re: pg_receivexlog and replication slots

On Fri, Jul 11, 2014 at 11:14 AM, Andres Freund <andres@2ndquadrant.com> wrote:

On 2014-07-11 11:08:48 +0200, Magnus Hagander wrote:

Is there a particular reason why pg_receivexlog only supports using
manually created slots but pg_recvlogical supports creating and
dropping them? Wouldn't it be good for consistency there?

I've added it to recvlogical because logical decoding isn't usable
without slots. I'm not sure what you'd want to create/drop a slot from
receivexlog for, but I'm not adverse to adding the capability.

I was mostly thinking for consistency, really. Using slots with
pg_receivexlog makes quite a bit of sense, even though it's useful
without it. But having the ability to create and drop (with compatible
commandline arguments of course) them directly when you set it up
would certainly be more convenient.

I'm guessing it's related to not being exposed over the replication
protocol?

It's exposed:
create_replication_slot:
/* CREATE_REPLICATION_SLOT slot PHYSICAL */
K_CREATE_REPLICATION_SLOT IDENT K_PHYSICAL

Hmm. You know, it would help if I actually looked at a 9.4 version of
the file when I check for functions of this kind :) Thanks!

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

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

#4Andres Freund
andres@anarazel.de
In reply to: Magnus Hagander (#3)
Re: pg_receivexlog and replication slots

On 2014-07-11 11:18:58 +0200, Magnus Hagander wrote:

On Fri, Jul 11, 2014 at 11:14 AM, Andres Freund <andres@2ndquadrant.com> wrote:

On 2014-07-11 11:08:48 +0200, Magnus Hagander wrote:

Is there a particular reason why pg_receivexlog only supports using
manually created slots but pg_recvlogical supports creating and
dropping them? Wouldn't it be good for consistency there?

I've added it to recvlogical because logical decoding isn't usable
without slots. I'm not sure what you'd want to create/drop a slot from
receivexlog for, but I'm not adverse to adding the capability.

I was mostly thinking for consistency, really. Using slots with
pg_receivexlog makes quite a bit of sense, even though it's useful
without it. But having the ability to create and drop (with compatible
commandline arguments of course) them directly when you set it up
would certainly be more convenient.

Ok. Do you plan to take care of it? If, I'd be fine with backpatching
it. I'm not likely to get to it right now :(

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

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

#5Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#4)
Re: pg_receivexlog and replication slots

On Fri, Jul 11, 2014 at 6:23 PM, Andres Freund <andres@2ndquadrant.com> wrote:

Ok. Do you plan to take care of it? If, I'd be fine with backpatching
it. I'm not likely to get to it right now :(

Actually I came up with the same need as Magnus, but a bit later,
so... Attached is a patch to support physical slot creation and drop
in pg_receivexlog with the addition of new options --create and
--drop. It would be nice to have that in 9.4, but I will not the one
deciding that at the end :) Code has been refactored with what is
already available in pg_recvlogical for the slot creation and drop.

Regards,
--
Michael

Attachments:

20140812_physical_slot_receivexlog.patchtext/x-patch; charset=US-ASCII; name=20140812_physical_slot_receivexlog.patchDownload+203-70
#6Noname
furuyao@pm.nttdata.co.jp
In reply to: Michael Paquier (#5)
Re: pg_receivexlog and replication slots

Actually I came up with the same need as Magnus, but a bit later, so...
Attached is a patch to support physical slot creation and drop in
pg_receivexlog with the addition of new options --create and --drop. It
would be nice to have that in 9.4, but I will not the one deciding that
at the end :) Code has been refactored with what is already available
in pg_recvlogical for the slot creation and drop.

I think that create/drop options of a slot is unnecessary.
It is not different from performing pg_create_physical_replication_slot() by psql.

At consistency with pg_recvlogical, do you think about --start?

Initial review.

The patch was not able to be applied to the source file at this morning time.

commit-id:5ff5bfb5f0d83a538766903275b230499fa9ebe1

[postgres postgresql-5ff5bfb]$ patch -p1 < 20140812_physical_slot_receivexlog.patch
patching file doc/src/sgml/ref/pg_receivexlog.sgml
patching file src/bin/pg_basebackup/pg_receivexlog.c
Hunk #2 FAILED at 80.
1 out of 7 hunks FAILED -- saving rejects to file src/bin/pg_basebackup/pg_receivexlog.c.rej
patching file src/bin/pg_basebackup/pg_recvlogical.c
patching file src/bin/pg_basebackup/streamutil.c
patching file src/bin/pg_basebackup/streamutil.h

The patch was applied to the source file before August 12.
warning comes out then make.

commit-id:6aa61580e08d58909b2a8845a4087b7699335ee0

[postgres postgresql-6aa6158]$ make > /dev/null
streamutil.c: In function ‘CreateReplicationSlot’:
streamutil.c:244: warning: suggest parentheses around ‘&&’ within ‘||’

Regards,

--
Furuya Osamu

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

#7Michael Paquier
michael@paquier.xyz
In reply to: Noname (#6)
Re: pg_receivexlog and replication slots

Thanks for your review.

On Fri, Aug 15, 2014 at 12:56 AM, <furuyao@pm.nttdata.co.jp> wrote:

At consistency with pg_recvlogical, do you think about --start?

I did not add that for the sake of backward-compatibility as in
pg_recvlogical an action is mandatory. It is not the case now of
pg_receivexlog.

[postgres postgresql-6aa6158]$ make > /dev/null
streamutil.c: In function 'CreateReplicationSlot':
streamutil.c:244: warning: suggest parentheses around '&&' within '||'

I see. Here is a rebased patch.
Regards,
--
Michael

Attachments:

20140815_slot_creation_pg_receivexlog_v2.patchtext/x-patch; charset=US-ASCII; name=20140815_slot_creation_pg_receivexlog_v2.patchDownload+203-70
#8Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#7)
Re: pg_receivexlog and replication slots

On Fri, Aug 15, 2014 at 5:17 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

Thanks for your review.

On Fri, Aug 15, 2014 at 12:56 AM, <furuyao@pm.nttdata.co.jp> wrote:

At consistency with pg_recvlogical, do you think about --start?

I did not add that for the sake of backward-compatibility as in
pg_recvlogical an action is mandatory. It is not the case now of
pg_receivexlog.

[postgres postgresql-6aa6158]$ make > /dev/null
streamutil.c: In function 'CreateReplicationSlot':
streamutil.c:244: warning: suggest parentheses around '&&' within '||'

I see. Here is a rebased patch.

Looking more at the code, IDENTIFY_SYSTEM management can be unified
into a single function. So I have written a newer version of the patch
grouping IDENTIFY_SYSTEM call into a single function for both
utilities, fixing at the same time a couple of other issues:
- correct use of TimelineID in code
- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)
That's not directly related to this patch, but making some corrections
is not going to hurt..

Regards,
--
Michael

Attachments:

20140818_physical_slot_receivexlog.patchtext/x-patch; charset=US-ASCII; name=20140818_physical_slot_receivexlog.patchDownload+265-141
#9Fujii Masao
masao.fujii@gmail.com
In reply to: Michael Paquier (#8)
Re: pg_receivexlog and replication slots

On Mon, Aug 18, 2014 at 2:38 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Fri, Aug 15, 2014 at 5:17 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

Thanks for your review.

On Fri, Aug 15, 2014 at 12:56 AM, <furuyao@pm.nttdata.co.jp> wrote:

At consistency with pg_recvlogical, do you think about --start?

I did not add that for the sake of backward-compatibility as in
pg_recvlogical an action is mandatory. It is not the case now of
pg_receivexlog.

[postgres postgresql-6aa6158]$ make > /dev/null
streamutil.c: In function 'CreateReplicationSlot':
streamutil.c:244: warning: suggest parentheses around '&&' within '||'

I see. Here is a rebased patch.

Looking more at the code, IDENTIFY_SYSTEM management can be unified
into a single function. So I have written a newer version of the patch
grouping IDENTIFY_SYSTEM call into a single function for both
utilities, fixing at the same time a couple of other issues:
- correct use of TimelineID in code
- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)
That's not directly related to this patch, but making some corrections
is not going to hurt..

Good catch! I found that libpqwalreceiver.c, etc have the same problem.
It's better to fix this separately. Patch attached.

Regards,

--
Fujii Masao

Attachments:

bugfix_identify_system_v1.patchtext/x-patch; charset=US-ASCII; name=bugfix_identify_system_v1.patchDownload+16-16
#10Fujii Masao
masao.fujii@gmail.com
In reply to: Fujii Masao (#9)
Re: pg_receivexlog and replication slots

On Mon, Aug 18, 2014 at 3:48 PM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Mon, Aug 18, 2014 at 2:38 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Fri, Aug 15, 2014 at 5:17 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

Thanks for your review.

On Fri, Aug 15, 2014 at 12:56 AM, <furuyao@pm.nttdata.co.jp> wrote:

At consistency with pg_recvlogical, do you think about --start?

I did not add that for the sake of backward-compatibility as in
pg_recvlogical an action is mandatory. It is not the case now of
pg_receivexlog.

[postgres postgresql-6aa6158]$ make > /dev/null
streamutil.c: In function 'CreateReplicationSlot':
streamutil.c:244: warning: suggest parentheses around '&&' within '||'

I see. Here is a rebased patch.

Looking more at the code, IDENTIFY_SYSTEM management can be unified
into a single function. So I have written a newer version of the patch
grouping IDENTIFY_SYSTEM call into a single function for both
utilities, fixing at the same time a couple of other issues:
- correct use of TimelineID in code
- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)
That's not directly related to this patch, but making some corrections
is not going to hurt..

Good catch! I found that libpqwalreceiver.c, etc have the same problem.
It's better to fix this separately. Patch attached.

BTW, the name of the forth column in IDENTIFY_SYSETM is "dbname". Maybe I don't
like this name because we usually use "datname" as the name of column which
identify the database name. For example, pg_database, pg_stat_activity, etc use
"datname".

Regards,

--
Fujii Masao

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

#11Michael Paquier
michael@paquier.xyz
In reply to: Fujii Masao (#9)
Re: pg_receivexlog and replication slots

On Mon, Aug 18, 2014 at 3:48 PM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Mon, Aug 18, 2014 at 2:38 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)
That's not directly related to this patch, but making some corrections
is not going to hurt..

Good catch! I found that libpqwalreceiver.c, etc have the same problem.
It's better to fix this separately. Patch attached.

Patch looks good to me. Once you push that I'll rebase the stuff on
this thread once again, that's going to conflict for sure. And now
looking at your patch there is additional refactoring possible with
IDENTIFY_SYSTEM and pg_basebackup as well...
Regards,
--
Michael

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

#12Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#11)
Re: pg_receivexlog and replication slots

On Mon, Aug 18, 2014 at 4:01 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Mon, Aug 18, 2014 at 3:48 PM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Mon, Aug 18, 2014 at 2:38 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

And now looking at your patch there is additional refactoring possible
with IDENTIFY_SYSTEM and pg_basebackup as well...

And attached is a rebased patch doing so.
Regards,
--
Michael

Attachments:

20140819_slot_creation_pg_receivexlog_v3.patchtext/x-patch; charset=US-ASCII; name=20140819_slot_creation_pg_receivexlog_v3.patchDownload+276-159
#13Fujii Masao
masao.fujii@gmail.com
In reply to: Michael Paquier (#11)
Re: pg_receivexlog and replication slots

On Mon, Aug 18, 2014 at 4:01 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Mon, Aug 18, 2014 at 3:48 PM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Mon, Aug 18, 2014 at 2:38 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)
That's not directly related to this patch, but making some corrections
is not going to hurt..

Good catch! I found that libpqwalreceiver.c, etc have the same problem.
It's better to fix this separately. Patch attached.

Patch looks good to me.

Okay, applied!

Once you push that I'll rebase the stuff on
this thread once again, that's going to conflict for sure. And now
looking at your patch there is additional refactoring possible with
IDENTIFY_SYSTEM and pg_basebackup as well...

Yep, that's possible. But since the patch needs to be back-patch to 9.4,
I didn't do the refactoring.

Regards,

--
Fujii Masao

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

#14Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#8)
Re: pg_receivexlog and replication slots

On 2014-08-18 14:38:06 +0900, Michael Paquier wrote:

- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)

Which is correct. We don't want to error out in the case where 3 columns
are returned because that'd unnecessarily break compatibility with <
9.4. Previously that check was != 3...

This isn't a bug.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

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

#15Fujii Masao
masao.fujii@gmail.com
In reply to: Andres Freund (#14)
Re: pg_receivexlog and replication slots

On Tue, Aug 19, 2014 at 5:52 PM, Andres Freund <andres@2ndquadrant.com> wrote:

On 2014-08-18 14:38:06 +0900, Michael Paquier wrote:

- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)

Which is correct. We don't want to error out in the case where 3 columns
are returned because that'd unnecessarily break compatibility with <
9.4. Previously that check was != 3...

This isn't a bug.

Okay, I understood why you didn't update those codes.

Since we don't allow replication between different major versions,
it's better to apply this change at least into libpqwalreceiver.c. Thought?

Regards,

--
Fujii Masao

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

#16Andres Freund
andres@anarazel.de
In reply to: Fujii Masao (#15)
Re: pg_receivexlog and replication slots

On 2014-08-19 18:02:32 +0900, Fujii Masao wrote:

On Tue, Aug 19, 2014 at 5:52 PM, Andres Freund <andres@2ndquadrant.com> wrote:

On 2014-08-18 14:38:06 +0900, Michael Paquier wrote:

- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)

Which is correct. We don't want to error out in the case where 3 columns
are returned because that'd unnecessarily break compatibility with <
9.4. Previously that check was != 3...

This isn't a bug.

Okay, I understood why you didn't update those codes.

Since we don't allow replication between different major versions,
it's better to apply this change at least into libpqwalreceiver.c. Thought?

We'd discussed that we'd rather keep it consistent. It also results in a
more explanatory error message lateron.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

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

#17Fujii Masao
masao.fujii@gmail.com
In reply to: Andres Freund (#16)
Re: pg_receivexlog and replication slots

On Tue, Aug 19, 2014 at 6:03 PM, Andres Freund <andres@2ndquadrant.com> wrote:

On 2014-08-19 18:02:32 +0900, Fujii Masao wrote:

On Tue, Aug 19, 2014 at 5:52 PM, Andres Freund <andres@2ndquadrant.com> wrote:

On 2014-08-18 14:38:06 +0900, Michael Paquier wrote:

- IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
check was done but in 9.4 this command returns 4 fields:
(PQntuples(res) != 1 || PQnfields(res) < 3)

Which is correct. We don't want to error out in the case where 3 columns
are returned because that'd unnecessarily break compatibility with <
9.4. Previously that check was != 3...

This isn't a bug.

Okay, I understood why you didn't update those codes.

Since we don't allow replication between different major versions,
it's better to apply this change at least into libpqwalreceiver.c. Thought?

We'd discussed that we'd rather keep it consistent. It also results in a
more explanatory error message lateron.

Hmm... okay, will revert the commit.

Regards,

--
Fujii Masao

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

#18Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#12)
Re: pg_receivexlog and replication slots

On Tue, Aug 19, 2014 at 2:49 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Mon, Aug 18, 2014 at 4:01 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Mon, Aug 18, 2014 at 3:48 PM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Mon, Aug 18, 2014 at 2:38 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

And now looking at your patch there is additional refactoring possible
with IDENTIFY_SYSTEM and pg_basebackup as well...

And attached is a rebased patch doing so.

I reworked this patch a bit to take into account the fact that the
number of columns to check after running IDENTIFY_SYSTEM is not always
4 as pointed out by Andres:
- pg_basebackup => 3
- pg_receivexlog => 3
- pg_recvlogical => 4

Regards,
--
Michael

Attachments:

20140826_slot_creation_pg_receivexlog_v4.patchtext/x-patch; charset=US-ASCII; name=20140826_slot_creation_pg_receivexlog_v4.patchDownload+279-159
#19Magnus Hagander
magnus@hagander.net
In reply to: Michael Paquier (#18)
Re: pg_receivexlog and replication slots

On Tue, Aug 26, 2014 at 9:43 AM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Tue, Aug 19, 2014 at 2:49 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Mon, Aug 18, 2014 at 4:01 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

On Mon, Aug 18, 2014 at 3:48 PM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Mon, Aug 18, 2014 at 2:38 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

And now looking at your patch there is additional refactoring possible
with IDENTIFY_SYSTEM and pg_basebackup as well...

And attached is a rebased patch doing so.

I reworked this patch a bit to take into account the fact that the
number of columns to check after running IDENTIFY_SYSTEM is not always
4 as pointed out by Andres:
- pg_basebackup => 3
- pg_receivexlog => 3
- pg_recvlogical => 4

As this is a number of patches rolled into one - do you happen to keep
them separate in your local repo? If so can you send them as separate
ones (refactor identify_system should be quite unrelated to supporting
replication slots, right?), for easier review? (if not, I'll just
split them apart mentally, but it's easier to review separately)

On the identify_system part - my understanding of the code is that
what you pass in as num_cols is the number of columns required for it
to work, right? We probably need to adjust the error message as well
in that case, because it's no longer what's "expected", it's what's
"required"? And we might want to include a hint about the reason
(wrong version)?

There's also a note "get LSN start position if necessary", but it
tries to do it unconditionally. What is the "if necessary" supposed to
refer to?

Actually - why do we even care about the 3 vs 4 in RunIdentifySystem,
as it never actually looks at the 4th column anyway? If we do
specifically want it to fail in the case of pg_recvlogical, we really
need to think up a better error message for it, and perhaps a
different way of specifying it?

Do we really want those Asserts? There is not a single Assert in
bin/pg_basebackup today - as is the case for most things in bin/. We
typically use regular if statements for things that "can happen", and
just ignore the others I think - since the callers are fairly simple
to trace.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

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

#20Michael Paquier
michael@paquier.xyz
In reply to: Magnus Hagander (#19)
Re: pg_receivexlog and replication slots

On Sun, Aug 31, 2014 at 10:45 PM, Magnus Hagander <magnus@hagander.net> wrote:

As this is a number of patches rolled into one - do you happen to keep
them separate in your local repo? If so can you send them as separate
ones (refactor identify_system should be quite unrelated to supporting
replication slots, right?), for easier review? (if not, I'll just
split them apart mentally, but it's easier to review separately)

Thanks for your review!

OK, here are 2 patches, the 2nd needing the 1st one:
1) Refactor IDENTIFY_SYSTEM and replslot create/drop APIs
2) Support for --create and --drop in pg_receivexlog

On the identify_system part - my understanding of the code is that
what you pass in as num_cols is the number of columns required for it
to work, right?

The argument is I would say cross-version compatibility and
consistency with the existing 9.4 code, but... (see below for the rest
of the story).

We probably need to adjust the error message as well
in that case, because it's no longer what's "expected", it's what's
"required"?

OK, changed this way.

And we might want to include a hint about the reason (wrong version)?

I am not sure about that, a simple error message looks fine IMO, and
there is no notion of error hinting in the other client utilities as
well.

There's also a note "get LSN start position if necessary", but it
tries to do it unconditionally. What is the "if necessary" supposed to
refer to?

That's remnant of some old code, so I removed it. Thanks for spotting that.

Actually - why do we even care about the 3 vs 4 in RunIdentifySystem,
as it never actually looks at the 4th column anyway? If we do
specifically want it to fail in the case of pg_recvlogical, we really
need to think up a better error message for it, and perhaps a
different way of specifying it?

Hm. I'd vote to simplify the code a bit based on the argument that the
current API only looks at the 3 first columns and does not care about
the 4th which is the plugin name.

Do we really want those Asserts? There is not a single Assert in
bin/pg_basebackup today - as is the case for most things in bin/. We
typically use regular if statements for things that "can happen", and
just ignore the others I think - since the callers are fairly simple
to trace.

OK, removed.

Regards,
--
Michael

Attachments:

0001-Refactoring-of-pg_basebackup-utilities.patchtext/x-diff; charset=US-ASCII; name=0001-Refactoring-of-pg_basebackup-utilities.patchDownload+183-161
0002-Support-for-replslot-creation-and-drop-in-pg_receive.patchtext/x-diff; charset=US-ASCII; name=0002-Support-for-replslot-creation-and-drop-in-pg_receive.patchDownload+87-2
#21Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#20)
#22Robert Haas
robertmhaas@gmail.com
In reply to: Magnus Hagander (#19)
#23Michael Paquier
michael@paquier.xyz
In reply to: Robert Haas (#22)
#24Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#23)
#25Amit Kapila
amit.kapila16@gmail.com
In reply to: Michael Paquier (#24)
#26Michael Paquier
michael@paquier.xyz
In reply to: Amit Kapila (#25)
#27Amit Kapila
amit.kapila16@gmail.com
In reply to: Michael Paquier (#26)
#28Michael Paquier
michael@paquier.xyz
In reply to: Amit Kapila (#27)
#29Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#28)
#30Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#29)
#31Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#30)
#32Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#31)
#33Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#32)
#34Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Andres Freund (#31)
#35Andres Freund
andres@anarazel.de
In reply to: Alvaro Herrera (#34)
#36Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#32)
#37Jan Wieck
JanWieck@Yahoo.com
In reply to: Andres Freund (#33)
#38Andres Freund
andres@anarazel.de
In reply to: Jan Wieck (#37)
#39Jan Wieck
JanWieck@Yahoo.com
In reply to: Andres Freund (#38)
#40Andres Freund
andres@anarazel.de
In reply to: Jan Wieck (#39)
#41Jan Wieck
JanWieck@Yahoo.com
In reply to: Andres Freund (#40)
#42Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#36)
#43Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#42)
#44Robert Haas
robertmhaas@gmail.com
In reply to: Andres Freund (#43)
#45Andres Freund
andres@anarazel.de
In reply to: Robert Haas (#44)
#46Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#45)
#47Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#46)
#48Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#43)
#49Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#46)
#50Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#47)
#51Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#49)
#52Robert Haas
robertmhaas@gmail.com
In reply to: Michael Paquier (#51)
#53Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#47)
#54Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#53)
#55Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#48)
#56Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#55)