pgsql: Do a pass of code review for the ALTER TABLE ADD INHERITS patch.

Started by Nonameover 19 years ago10 messages
#1Noname
neilc@postgresql.org

Log Message:
-----------
Do a pass of code review for the ALTER TABLE ADD INHERITS patch. Keep
the read lock we hold on the table's parent relation until commit.
Update equalfuncs.c for the new field in AlterTableCmd. Various
improvements to comments, variable names, and error reporting.

There is room for further improvement here, but this is at least
a step in the right direction.

Modified Files:
--------------
pgsql/src/backend/commands:
tablecmds.c (r1.190 -> r1.191)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c.diff?r1=1.190&r2=1.191)
pgsql/src/backend/nodes:
copyfuncs.c (r1.340 -> r1.341)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/copyfuncs.c.diff?r1=1.340&r2=1.341)
equalfuncs.c (r1.274 -> r1.275)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/equalfuncs.c.diff?r1=1.274&r2=1.275)
pgsql/src/test/regress/expected:
alter_table.out (r1.95 -> r1.96)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/alter_table.out.diff?r1=1.95&r2=1.96)

#2Bruce Momjian
bruce@momjian.us
In reply to: Noname (#1)
Re: [COMMITTERS] pgsql: Do a pass of code review for the ALTER TABLE

Neil Conway wrote:

Log Message:
-----------
Do a pass of code review for the ALTER TABLE ADD INHERITS patch. Keep
the read lock we hold on the table's parent relation until commit.
Update equalfuncs.c for the new field in AlterTableCmd. Various
improvements to comments, variable names, and error reporting.

There is room for further improvement here, but this is at least
a step in the right direction.

Thanks, that is what was needed. The author obviously took the patch as
far as he could, and we needed to adjust his XXX areas, rather than not
apply the patch and have the code drifting.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Alvaro Herrera
alvherre@commandprompt.com
In reply to: Bruce Momjian (#2)
Re: [COMMITTERS] pgsql: Do a pass of code review for the ALTER TABLE

Bruce Momjian wrote:

Neil Conway wrote:

Log Message:
-----------
Do a pass of code review for the ALTER TABLE ADD INHERITS patch. Keep
the read lock we hold on the table's parent relation until commit.
Update equalfuncs.c for the new field in AlterTableCmd. Various
improvements to comments, variable names, and error reporting.

There is room for further improvement here, but this is at least
a step in the right direction.

Thanks, that is what was needed. The author obviously took the patch as
far as he could, and we needed to adjust his XXX areas, rather than not
apply the patch and have the code drifting.

Hmm, is this how we should do things? I mean, should I finish the
autovacuum parts of my relminxid patch, apply it, and then hope for
someone to fix the mistaeks? And if we don't see any failure in the
buildfarm, assume that all is well?

To me this is really the easiest way, but I have a hard time convincing
myself that I want to have it easy but break things in a way that nobody
notices. The other day when I typoed a commit to the 8.1 branch I was
all red in the face. I wonder what will happen if someone points to me
or Greg as causing major breakage somewhere, just because the patch was
applied in a hurry without careful review.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#4Andrew Dunstan
andrew@dunslane.net
In reply to: Alvaro Herrera (#3)
Re: [COMMITTERS] pgsql: Do a pass of code review for the

Alvaro Herrera wrote:

Thanks, that is what was needed. The author obviously took the patch as
far as he could, and we needed to adjust his XXX areas, rather than not
apply the patch and have the code drifting.

Hmm, is this how we should do things? I mean, should I finish the
autovacuum parts of my relminxid patch, apply it, and then hope for
someone to fix the mistaeks? And if we don't see any failure in the
buildfarm, assume that all is well?

To me this is really the easiest way, but I have a hard time convincing
myself that I want to have it easy but break things in a way that nobody
notices. The other day when I typoed a commit to the 8.1 branch I was
all red in the face. I wonder what will happen if someone points to me
or Greg as causing major breakage somewhere, just because the patch was
applied in a hurry without careful review.

I am guilty of a similar recent sin that Tom caught. But, like you, I am
opposed to lessening the stability in the code base, which is something
we should be proud of and guard carefully.

cheers

andrew

#5Bruce Momjian
bruce@momjian.us
In reply to: Alvaro Herrera (#3)
Re: [COMMITTERS] pgsql: Do a pass of code review for the

Alvaro Herrera wrote:

Bruce Momjian wrote:

Neil Conway wrote:

Log Message:
-----------
Do a pass of code review for the ALTER TABLE ADD INHERITS patch. Keep
the read lock we hold on the table's parent relation until commit.
Update equalfuncs.c for the new field in AlterTableCmd. Various
improvements to comments, variable names, and error reporting.

There is room for further improvement here, but this is at least
a step in the right direction.

Thanks, that is what was needed. The author obviously took the patch as
far as he could, and we needed to adjust his XXX areas, rather than not
apply the patch and have the code drifting.

Hmm, is this how we should do things? I mean, should I finish the
autovacuum parts of my relminxid patch, apply it, and then hope for
someone to fix the mistaeks? And if we don't see any failure in the
buildfarm, assume that all is well?

To me this is really the easiest way, but I have a hard time convincing
myself that I want to have it easy but break things in a way that nobody
notices. The other day when I typoed a commit to the 8.1 branch I was
all red in the face. I wonder what will happen if someone points to me
or Greg as causing major breakage somewhere, just because the patch was
applied in a hurry without careful review.

The author had been through several iterations of the patch, and I
needed to clean it up to look more like our code.

The XXX comments where of the variety where he was asking for
confirmation on things, and we can adjust those after application.
Doing it with his version of the patch would have been harder. If the
issues aren't addressed, the patch is eventually reverted, as we have
done in the past.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#6paolo romano
paolo.romano@yahoo.it
In reply to: Alvaro Herrera (#3)
Re: [COMMITTERS] pgsql: Do a pass of code review for the ALTER TABLE

I'm keeping on studying multixact.c and log management, and I hope you can help me, as usual, in clearing my doubts.

My doubts now concern MultixactID wrap-around management.
Afaics, it is possible to spawn multixactids so quickly to have a wrap-around and to start overwriting the data stored in the offset slru (but analogous considerations apply to the member slru as well). This would cause corruption, if the overwritten info was still needed, e.g., by a (very) long-running transaction. This is of course very unlikely in practice, but yet still possible in theory.

In GetNewMultiXactId () wrap-around of MultiXactId seems to be simply handled this way:

00780 _/* Handle wraparound of the nextMXact counter */
00781 if (MultiXactState->nextMXact < FirstMultiXactId)
00782 MultiXactState->nextMXact = FirstMultiXactId;

I cannot see how this may avoid possible overwriting of still needed data. To address such an issue shouldn't one need to check against OldestMemberMXactId, OldestVisibleMXactId? Or, alternatively, rely on an approach similar to the one taken to handle standard XID generation (xidWarnLimit, see GetNewTransactionId)?

Is it me who's missing something or is it just that such a case has been considered so unlikely not to motivate additional overheads/checks?

Thanks in advance!

Paolo
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com

#7paolo romano
paolo.romano@yahoo.it
In reply to: paolo romano (#6)
MultiXactID Wrap-Around

ops, i did forget to update the e-mail subject, sorry. I am reposting it with an appropriate one.

-------------------------------------------------------------------------------- I'm keeping on studying multixact.c and log management, and I hope you can help me, as usual, in clearing my doubts.

My doubts now concern MultixactID wrap-around management.
Afaics, it is possible to spawn multixactids so quickly to have a wrap-around and to start overwriting the data stored in the offset slru (but analogous considerations apply to the member slru as well). This would cause corruption, if the overwritten info was still needed, e.g., by a (very) long-running transaction. This is of course very unlikely in practice, but yet still possible in theory.

In GetNewMultiXactId () wrap-around of MultiXactId seems to be simply handled this way:

00780 _/* Handle wraparound of the nextMXact counter */
00781 if (MultiXactState->nextMXact < FirstMultiXactId)
00782 MultiXactState->nextMXact = FirstMultiXactId;

I cannot see how this may avoid possible overwriting of still needed data. To address such an issue shouldn't one need to check against OldestMemberMXactId, OldestVisibleMXactId? Or, alternatively, rely on an approach similar to the one taken to handle standard XID generation (xidWarnLimit, see GetNewTransactionId)?

Is it me who's missing something or is it just that such a case has been considered so unlikely not to motivate additional overheads/checks?

Thanks in advance!

Paolo

Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com

#8Andrew Dunstan
andrew@dunslane.net
In reply to: paolo romano (#7)
Re: MultiXactID Wrap-Around

paolo romano wrote:

ops, i did forget to update the e-mail subject, sorry. I am reposting
it with an appropriate one.

Please do NOT create a post on a new subject by using an MUA's reply
mechanism, even if you replace the subject. The MUA will create an
in-reply-to header which will be totally inappropriate and confuse other
MUAs and achive processors that use such headers for thread
construction. Only use a reply facility when you are genuinely replying
on the same subject. This goes for webmail MUAs too (yahoo, squirrelmail
etc.) The right way to get the address is to put it in your address book
or as a last resort cut and paste it.

cheers

andrew

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: paolo romano (#7)
Re: MultiXactID Wrap-Around

paolo romano <paolo.romano@yahoo.it> writes:

My doubts now concern MultixactID wrap-around management.
Afaics, it is possible to spawn multixactids so quickly to have a
wrap-around and to start overwriting the data stored in the offset
slru (but analogous considerations apply to the member slru as
well).

I looked into this when the multixact code was written. There is a
theoretical risk but I think it's entirely theoretical. MXIDs are
unlikely to be consumed faster than XIDs over the long term, and also
can be recycled sooner. So you'd run up against XID wraparound (which
we do defend against) first.

regards, tom lane

#10paolo romano
paolo.romano@yahoo.it
In reply to: Tom Lane (#9)
Re: MultiXactID Wrap-Around

Thank you for the feed-back. In fact the risk seems neglibible, but it means that at least I'm not misunderstanding what that code does...

Tom Lane <tgl@sss.pgh.pa.us> ha scritto: paolo romano
writes:

My doubts now concern MultixactID wrap-around management.
Afaics, it is possible to spawn multixactids so quickly to have a
wrap-around and to start overwriting the data stored in the offset
slru (but analogous considerations apply to the member slru as
well).

I looked into this when the multixact code was written. There is a
theoretical risk but I think it's entirely theoretical. MXIDs are
unlikely to be consumed faster than XIDs over the long term, and also
can be recycled sooner. So you'd run up against XID wraparound (which
we do defend against) first.

regards, tom lane

Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com