Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ixWoh-0003bT-TI for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Jan 2020 13:58:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ixWog-00085B-0F for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Jan 2020 13:58:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ixWof-000853-HP for pgsql-hackers@lists.postgresql.org; Fri, 31 Jan 2020 13:58:37 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ixWoc-0004ki-PY for pgsql-hackers@postgresql.org; Fri, 31 Jan 2020 13:58:36 +0000 Received: by mail-qt1-x844.google.com with SMTP id l19so5411692qtq.8 for ; Fri, 31 Jan 2020 05:58:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=2XZ9U3dFhRQ3zO3c3EhhGwiUP9jfm0rEmlmEt+5xYko=; b=O1g3dO1HCQKRufYrY7hEDBJsisdgKTw4OCc46+FEo+5+X0BOqAKYGh9GQgG1aWecvK Ho1igFEEM9xwY9+SIlO2ajTwMLXSe5a46mRu0hBtWB4OmwIm4Jh40McZ2MVbqNHnLC+P JJhl5MOcijxFnHRYPijEoSuLGUxJnAHoF0nX1eoblgT33Dsg2QjmdCfOU9TjTGrtzLyl S6MJ4hkyNlEqQEVDIK0VwpMyicr60/1caUcLp37B3QosqXRvh1EPOhOAXSuw6uTkkekN YnkokKPh4SvYxccw4ibhbYjWC+RWcV/sRPjilaW1WfSA10XEfyi1eyx50G3FjH2oMbzA YHwg== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=2XZ9U3dFhRQ3zO3c3EhhGwiUP9jfm0rEmlmEt+5xYko=; b=kL3qJOKxZCBs+Rbku1aKQRAghnHkiZ5cYY72Qu0NfBDZ2Xe8oqWOAE+VYZ4i2gaBii Te3CiLNDcmhKi/aAramHGuLpSWbGwM1j6jfqB3cwVvIG4THcz9oI2CgKZGEZ+d+ld+3c K2ZvyaCelUQSqeIIZdzC5Y7ltlgor3YsFV0PPGVxceCECVZWQ138jXiA1p8pWB10oj4x FAsXxkBhbJInbn1KiqTGOiVIFIZdiTHGdVuL5SVsZXnXODHpl3/rHKMWDcdRTmFCA4ko kWaWaqZeC1NenQMFqAeVaMXx8mEN44jh9LGlK+M/W2i5hYTCYt/VwhBTsQciusDQvIk+ HNAw== X-Gm-Message-State: APjAAAUt9LqKUYSJKFTIhxlqbLrBM60thRATum3uMHHa9i75j+wta6cb Xsvh6Mm94YO2BBg7qYqJcn9J8pCqeeQ= X-Google-Smtp-Source: APXvYqyppMdttD2KLBrQ3wIYmd9Fddf0OXezExwqTZJHAFsDghim433EvKV2AlahqMAD6/lwp/o++Q== X-Received: by 2002:ac8:4c90:: with SMTP id j16mr10667880qtv.298.1580479113890; Fri, 31 Jan 2020 05:58:33 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([179.56.96.77]) by smtp.gmail.com with ESMTPSA id z8sm4976649qth.16.2020.01.31.05.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2020 05:58:33 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 12A79300839; Fri, 31 Jan 2020 10:58:31 -0300 (-03) Date: Fri, 31 Jan 2020 10:58:31 -0300 From: Alvaro Herrera To: Konstantin Knizhnik Cc: PostgreSQL Hackers Subject: Re: Missing break in RelationFindReplTupleSeq Message-ID: <20200131135831.GA1550@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <379743f6-ae91-b866-f7a2-5624e6d2b0a4@postgrespro.ru> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2020-Jan-31, Konstantin Knizhnik wrote: > Eventually we find out that logical replication in the current version of > Postgres works significantly slower on table with replica identity full than > old pglogical implementation. > > The comment to RelationFindReplTupleSeq says: > >     Note that this stops on the first matching tuple. > > But actually this function continue traversal until end of the table even if > tuple was found. > I wonder if break; should be added to the end of for loop. Wow, you're right, and the "break" is missing there. I propose it like this. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --3V7upXqbjpZ4EhLz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="fix-replident-full.patch" diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c index 582b0cb017..30cba89da7 100644 --- a/src/backend/executor/execReplication.c +++ b/src/backend/executor/execReplication.c @@ -327,6 +327,9 @@ retry: XactLockTableWait(xwait, NULL, NULL, XLTW_None); goto retry; } + + /* Found our tuple and it's not locked */ + break; } /* Found tuple, try to lock it in the lockmode. */ --3V7upXqbjpZ4EhLz--