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 1jOYV9-0001dI-Ma for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2020 03:14:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jOYV7-00022K-Rl for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2020 03:14:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jOYV7-000221-Kf for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2020 03:14:09 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jOYV5-0006vy-5a for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2020 03:14:08 +0000 Received: by mail-pl1-x644.google.com with SMTP id g2so740048plo.3 for ; Tue, 14 Apr 2020 20:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QyAJW/5ne+Yd/tkgZOTsB/HZxCtwwh33/xr3xM21uJ4=; b=feS3OyF7dAeKiCQgMCRTC6vOjrYTYK0plK2Ifes0g+D804hevKhkpHaF8mOPlHW1Bn fjN8OZFNGJpDKe33g2DZ0mwmumma4W9OKAQB7cY+hdFLaaJGLyF2VuDHQD3dDrjZW747 +dUbWsufCHa2XB2xWBC3EJxlNPUu27MCEleX4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QyAJW/5ne+Yd/tkgZOTsB/HZxCtwwh33/xr3xM21uJ4=; b=UwRNtDDyjSBDPnF95FcBhXkmnh/escRi70NGFnEeDM3vuTkZcQWTQkWtrBJehlNXGX nhQxHirsVFM/dXXAGKUZe+xYj819/5Vjp3TIvud0JLpZCjIFT19z0QRtzoHANkjNawyg f+i50r5rTaHuQMVW5mqQow9Yf+52973Yml4D/sK2eblFFacq0Hty9DhjeLJcQlgN7omD euY8H3/XXdHlcfkGEb7AnmDaS5xHQKVA9fbNCU2EiQdqjavmvVuiKNx1l5eDowVJ/WnJ G0A+7bWIBTR9O2J+oUrhChOcicedapqsIqzIHR6MLVDyKZ+Sp3Xge/soUm1m/FFcMHzd iKtA== X-Gm-Message-State: AGi0PuYinZsOqV9B+uP87Vqdp5wuKIoeiHuTCqgyVt+aZL+9VoY/py7Y umtMBQuzfuXZw4h65IMT1+MwVg== X-Google-Smtp-Source: APiQypKvF5lEWlVEIbe+VJtuIrJPOUiJSC/jxBt/Uln2ZZzS+6WRdeiywXyIxUgJgxVKiP8GLV62YQ== X-Received: by 2002:a17:90a:1a10:: with SMTP id 16mr3884292pjk.31.1586920445813; Tue, 14 Apr 2020 20:14:05 -0700 (PDT) Received: from rfd.leadboat.com (108-233-125-46.lightspeed.sntcca.sbcglobal.net. [108.233.125.46]) by smtp.gmail.com with ESMTPSA id na18sm13616039pjb.31.2020.04.14.20.14.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2020 20:14:04 -0700 (PDT) Date: Tue, 14 Apr 2020 20:14:02 -0700 From: Noah Misch To: Tom Lane Cc: Kyotaro Horiguchi , masahiko.sawada@2ndquadrant.com, masao.fujii@oss.nttdata.com, pgsql-hackers@lists.postgresql.org Subject: Re: Race condition in SyncRepGetSyncStandbysPriority Message-ID: <20200415031402.GA959799@rfd.leadboat.com> References: <20200413.153101.688623432137444694.horikyota.ntt@gmail.com> <8325.1586828060@sss.pgh.pa.us> <20200414.183538.344904915964423903.horikyota.ntt@gmail.com> <15616.1586872362@sss.pgh.pa.us> <13059.1586896360@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13059.1586896360@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Apr 14, 2020 at 04:32:40PM -0400, Tom Lane wrote: > I wrote: > > It doesn't seem to me to be that hard to implement the desired > > semantics for synchronous_standby_names with inconsistent info. > > In FIRST mode you basically just need to take the N smallest > > priorities you see in the array, but without assuming there are no > > duplicates or holes. It might be a good idea to include ties at the > > end, that is if you see 1,2,2,4 or 1,3,3,4 and you want 2 sync > > standbys, include the first three of them in the calculation until > > the inconsistency is resolved. In ANY mode I don't see that > > inconsistent priorities matter at all. > > Concretely, I think we ought to do the attached, or something pretty > close to it. > > I'm not really happy about breaking ties based on walsnd_index, > but I see that there are several TAP test cases that fail if we > do something else. I'm inclined to think those tests are bogus ... > but I won't argue to change them right now. This passes the test battery I wrote in preparation for the 2020-02 thread.