pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Aleksander Alekseev <a.alekseev@postgrespro.ru>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Robert Haas <rhaas@postgresql.org>
Subject: Re: Yet another small patch - reorderbuffer.c:1099
Date: Tue, 5 Apr 2016 11:38:27 -0300
Message-ID: <20160405143827.GA258373@alvherre.pgsql> (raw)
In-Reply-To: <CANP8+jJWjt-RD8oA_ya=MXcs3OPmg4Qxt=JUy_1ovnBJ5Fi6=g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Simon Riggs wrote:
> On 5 April 2016 at 10:12, Andres Freund <andres@anarazel.de> wrote:
> 
> > On 2016-04-05 12:07:40 +0300, Aleksander Alekseev wrote:
> > > > I recall discussing this code with Andres, and I think that he has
> > > > mentioned me this is intentional, because should things be changed for
> > > > a reason or another in the future, we want to keep in mind that a list
> > > > of TXIDs and a list of sub-TXIDs should be handled differently.
> > >
> > > I see. If this it true I think there should be a comment that explains
> > > it. When you read such a code you suspect a bug. Not mentioning that
> > > static code analyzers (I'm currently experimenting with Clang and PVS
> > > Studio) complain about code like this.
> >
> > There's different comments in both branches...
> 
> Then one or both of the comments is incomplete.

IMO the code is wrong.  There should be a single block comment saying
something like "Remove the node from its containing list.  In the FOO
case, the list corresponds to BAR and therefore we delete it because
BAZ.  In the QUUX case the list is PLUGH and we delete in because THUD."
Then a single line dlist_delete(...) follows.

The current arrangement looks bizantine to me, for no reason.  If we
think that one of the two branches might do something additional to the
list deletion, surely that will be in a separate stanza with its own
comment; and if we ever want to remove the list deletion from one of the
two cases (something that strikes me as unlikely) then we will need to
fix the comment, too.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, 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



view thread (11+ messages)  latest in thread

Message-ID: <20160405143827.GA258373@alvherre.pgsql>
Permalink:  ../20160405143827.GA258373@alvherre.pgsql/
Also on:    postgresql.org/message-id/20160405143827.GA258373@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@2ndquadrant.com, simon@2ndQuadrant.com, andres@anarazel.de, a.alekseev@postgrespro.ru, michael.paquier@gmail.com, rhaas@postgresql.org
  Subject: Re: Yet another small patch - reorderbuffer.c:1099
  In-Reply-To: <20160405143827.GA258373@alvherre.pgsql>
  References: <CANP8+jJWjt-RD8oA_ya=MXcs3OPmg4Qxt=JUy_1ovnBJ5Fi6=g@mail.gmail.com> <20160405143827.GA258373@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox