Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIfne-0006qc-NQ for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Sep 2020 22:21:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kIfnd-00026q-La for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Sep 2020 22:21:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIfnd-00026j-Es for pgsql-hackers@lists.postgresql.org; Wed, 16 Sep 2020 22:21:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIfnb-0003Uh-0O for pgsql-hackers@lists.postgresql.org; Wed, 16 Sep 2020 22:21:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 08GML8b4039195; Wed, 16 Sep 2020 18:21:08 -0400 From: Tom Lane To: Alvaro Herrera cc: Michael Paquier , pgsql-hackers@lists.postgresql.org Subject: Re: Gripes about walsender command processing In-reply-to: <20200916221422.GA24095@alvherre.pgsql> References: <20200916221422.GA24095@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 16 Sep 2020 19:14:22 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <39193.1600294868.1@sss.pgh.pa.us> Date: Wed, 16 Sep 2020 18:21:08 -0400 Message-ID: <39194.1600294868@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2020-Sep-16, Tom Lane wrote: >> I don't see an easy way to improve on it though. The only obvious >> alternative would be to put another switch before the main one that >> just fills a "const char *cmdtag" variable, but that seems ugly. > The alternative of doing the assignment in each case of the same switch > does not look too terrible: > case T_IdentifySystemCmd: > + cmdtag = "IDENTIFY_SYSTEM"; > + set_ps_display(cmdtag); > IdentifySystem(); > + EndReplicationCommand(cmdtag); > break; > case T_BaseBackupCmd: > + cmdtag = "BASE_BACKUP"; > + set_ps_display(cmdtag); > PreventInTransactionBlock(true, cmdtag); > SendBaseBackup((BaseBackupCmd *) cmd_node); > + EndReplicationCommand(cmdtag); > break; Yeah, that works for me. It doesn't allow for having just one set_ps_display() call ahead of the switch, but that isn't that big a loss. We cannot merge the EndReplicationCommand calls to after the switch, because some of the cases don't want one here; so that partial duplication is inescapable. Note that your changes need to be backpatched into v13, because AFAICS this code is violating the FE/BE protocol right now --- it's just luck that libpq isn't moaning about extra CommandComplete messages. But I don't think we want to change the ps title behavior in v13 at this late date, so that part should be HEAD-only. regards, tom lane