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 1mrfrf-0006pE-D9 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Nov 2021 12:34:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mrfre-0005iL-99 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Nov 2021 12:34:34 +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 1mrfrd-0005i6-Ur for pgsql-hackers@lists.postgresql.org; Mon, 29 Nov 2021 12:34:33 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mrfrb-0007DH-QO for pgsql-hackers@lists.postgresql.org; Mon, 29 Nov 2021 12:34:33 +0000 Received: by mail-lf1-x136.google.com with SMTP id bi37so44154329lfb.5 for ; Mon, 29 Nov 2021 04:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4NHfWoz6iOFe4uSe46CgXEeBtoER6kDo4+ZpFBzDVjA=; b=EmXGhXGcm5bLJ3ua7sRstpek7O8Fi+of80rnmzGEkCSLH5irSyuw9dPoIf9GHmHdeR FcT5UGtLe2hTNvGM0Cq8x03VC5Ps2uUIpxL23Yx26eW34EHuPVUHDWLdIvLmDTL7q1VF TYvc+J3oFh0zDcI2m0uDkjqXL+ZhSM5UwVOq4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4NHfWoz6iOFe4uSe46CgXEeBtoER6kDo4+ZpFBzDVjA=; b=ian+u+BanZ9ZIuymfSxcUfHsSeqfqK6YFwHrebgt6SKdgym4ERVrLPB7M7p+KctHwu xQoVNXN/9SOTo1uBNTAojkY+76EUyPVzPUxlwy4ibXs0WQfW8GeSrXYk2ADX+2BiE9ll yl6V3l5+mS33+x31Q60Z3ZMEYc631gLqgIs1zuadIckKY48r6JVCx5alayByCPzAPXLU W1uos9dcEJRAHZZ6J7VLEq6xJtVx0xTgzc8u0l5eonLGlMrcHMJqKSaK/A8SBZJk0+rt BNEApaA7akpBsrjMSn+e0yYeLYxxW4mXhztjRXXH1tf+23qPLN28FJauSvCBfq21tE3i 2Syg== X-Gm-Message-State: AOAM531GuxHfO0XC4cLMp2CA+/PJwDnPlU1V3+wf0wW1gHucothB6fDZ 1p0QMlImRUjgbTa0mdHAcYMrJTkP3JlRTuBd1/gdAQ== X-Google-Smtp-Source: ABdhPJxPcGMoVMA71gq7oS0h/H22kWhUVT5zn+gXv7LqjcR7WVmiNjee7ny9cnqdrHdxlPUmxzXq+iICOvsA65U9iMw= X-Received: by 2002:ac2:4ad0:: with SMTP id m16mr48105792lfp.29.1638189271079; Mon, 29 Nov 2021 04:34:31 -0800 (PST) MIME-Version: 1.0 References: <54449d7bea79263e937266ad6ebc65b3@oss.nttdata.com> <4e64bb8a0a88f5b6ac5a8901377c81af@oss.nttdata.com> In-Reply-To: From: Zhihong Yu Date: Mon, 29 Nov 2021 04:36:10 -0800 Message-ID: Subject: Re: [Proposal] Add foreign-server health checks infrastructure To: "kuroda.hayato@fujitsu.com" Cc: Shinya Kato , "pgsql-hackers@lists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000093f0d505d1eca982" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000093f0d505d1eca982 Content-Type: text/plain; charset="UTF-8" On Mon, Nov 29, 2021 at 12:51 AM kuroda.hayato@fujitsu.com < kuroda.hayato@fujitsu.com> wrote: > Dear Zhihong, > > Thank you for giving comments! I'll post new patches later. > > > +#define HOLD_CHECKING_REMOTE_SERVERS_INTERRUPTS() > (CheckingRemoteServersHoldoffCount++) > > > > The macro contains only one operation. Can the macro be removed (with > `CheckingRemoteServersHoldoffCount++` inlined) ? > > Hmm, these HOLD/RESUME macros are followed HOLD_INTERRUPUST() and > HOLD_CANCEL_INTERRUPTS(): > > ``` > #define HOLD_INTERRUPTS() (InterruptHoldoffCount++) > > #define RESUME_INTERRUPTS() \ > do { \ > Assert(InterruptHoldoffCount > 0); \ > InterruptHoldoffCount--; \ > } while(0) > > #define HOLD_CANCEL_INTERRUPTS() (QueryCancelHoldoffCount++) > > #define RESUME_CANCEL_INTERRUPTS() \ > do { \ > Assert(QueryCancelHoldoffCount > 0); \ > QueryCancelHoldoffCount--; \ > } while(0) > > #define START_CRIT_SECTION() (CritSectionCount++) > > #define END_CRIT_SECTION() \ > do { \ > Assert(CritSectionCount > 0); \ > CritSectionCount--; \ > } while(0) > ``` > > So I want to keep the current style. Could you tell me if you have any > other reasons? > > > + if (CheckingRemoteServersTimeoutPending && > CheckingRemoteServersHoldoffCount != 0) > > + { > > + /* > > + * Skip checking foreign servers while reading messages. > > + */ > > + InterruptPending = true; > > + } > > + else if (CheckingRemoteServersTimeoutPending) > > > > Would the code be more readable if the above two if blocks be moved > inside one enclosing if block (factoring the common condition)? > > > > + if (CheckingRemoteServersTimeoutPending) > > +1. Will fix. > > Best Regards, > Hayato Kuroda > FUJITSU LIMITED > Hi, It is Okay to keep the macros. Thanks --00000000000093f0d505d1eca982 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Mon, Nov 29, 2021 at 12:51 AM kuroda.hayato@fujitsu.com <= kuroda.hayato@fujitsu.com&= gt; wrote:
Dear = Zhihong,

Thank you for giving comments! I'll post new patches later.

> +#define HOLD_CHECKING_REMOTE_SERVERS_INTERRUPTS()=C2=A0 (CheckingRemo= teServersHoldoffCount++)
>
> The macro contains only one operation. Can the macro be removed (with = `CheckingRemoteServersHoldoffCount++` inlined) ?

Hmm, these HOLD/RESUME macros are followed HOLD_INTERRUPUST() and HOLD_CANC= EL_INTERRUPTS():

```
#define HOLD_INTERRUPTS()=C2=A0 (InterruptHoldoffCount++)

#define RESUME_INTERRUPTS() \
do { \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Assert(InterruptHoldoffCount > 0); \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 InterruptHoldoffCount--; \
} while(0)

#define HOLD_CANCEL_INTERRUPTS()=C2=A0 (QueryCancelHoldoffCount++)

#define RESUME_CANCEL_INTERRUPTS() \
do { \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Assert(QueryCancelHoldoffCount > 0); \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 QueryCancelHoldoffCount--; \
} while(0)

#define START_CRIT_SECTION()=C2=A0 (CritSectionCount++)

#define END_CRIT_SECTION() \
do { \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Assert(CritSectionCount > 0); \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 CritSectionCount--; \
} while(0)
```

So I want to keep the current style. Could you tell me if you have any othe= r reasons?

> +=C2=A0 =C2=A0if (CheckingRemoteServersTimeoutPending && Check= ingRemoteServersHoldoffCount !=3D 0)
> +=C2=A0 =C2=A0{
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0/*
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Skip checking foreign servers while rea= ding messages.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0InterruptPending =3D true;
> +=C2=A0 =C2=A0}
> +=C2=A0 =C2=A0else if (CheckingRemoteServersTimeoutPending)
>
> Would the code be more readable if the above two if blocks be moved in= side one enclosing if block (factoring the common condition)?
>
> +=C2=A0 =C2=A0if (CheckingRemoteServersTimeoutPending)

+1. Will fix.

Best Regards,
Hayato Kuroda
FUJITSU LIMITED

Hi,

It is Okay to keep the macros.

Thanks
<= /div>
--00000000000093f0d505d1eca982--