Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGaAz-00077c-DR for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Dec 2016 23:38:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cGaAy-0004RU-Uw for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Dec 2016 23:38:32 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cGaAy-0004RE-4n for pgsql-hackers@postgresql.org; Mon, 12 Dec 2016 23:38:32 +0000 Received: from mail-wj0-x236.google.com ([2a00:1450:400c:c01::236]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cGaAv-0003SQ-8I for pgsql-hackers@postgresql.org; Mon, 12 Dec 2016 23:38:30 +0000 Received: by mail-wj0-x236.google.com with SMTP id tk12so86268050wjb.3 for ; Mon, 12 Dec 2016 15:38:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=MRXO7O68z2zqqEEIWf0PT/PJDZm6ITzN4RP9fDjXOuM=; b=iXhBWTVnh1tfhgnxzkulLj5upQMf9xt/rtuadmS5Owzeg/5qqDRLEa1uJcrvNbCFWO iXhwlyrpKfWya/tQtqIo2ZjhvChQ0HlKK5u0J1fxvQNo8UdzSTYYfDPHSIVD0QRI6luN JjgEWD9jtzjho8jljcyTuB7/k/6csv8q+/yQ08mtdoQO3/vKYWu6gtEKFq/+2rTrLCcU FAiRTniMSDthMn/2CSXqHIkyz0nbmwa+zlmn9gpusDYJIPijTrdnF6qfxMsRKoI/A7p8 PZAeQG8LA97el8+ZNt/kkrGOEXWBWgAgwqgBSXIho+xgtUi2aNDKw6wK64bmBkDATf0q i5qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=MRXO7O68z2zqqEEIWf0PT/PJDZm6ITzN4RP9fDjXOuM=; b=YYq1UYsjRtfInI3wRxPZpg2qytpeEFFJrveQYsh0rLh4J1kGvbUXBuMAPB72M+nZkE +tRrG8nwK0MpoPae7rmjdInGWu48Yi5vPHFjeMWYx2/8qsXEPI++ycmOJ2LTcV/apFP3 2XgxVT5yCUzNqtaOwe/HG6NW3u4FBHtoQ1ltAGqUC9TArX9MaW/VGcGbocuc0n/RMFDG tZAt2cmdmmzOJmy1NtwS5kPViwq10dXOkBALo550cbvIKL09AUDsOvqjqrSdl2PidAW9 9TMAeHmMqZulg6VY+F9jC75DH370J9z2AcBYqo8ux6y22vJfvcVMZeLbvXU/WO5cmePd 5N9Q== X-Gm-Message-State: AKaTC01GzgtyFx70dfGtoPvrJcVFLYJO8V84PjWE+yfPqlOAthgKMAjqdalqNUauMKlmS6txW5QScYgha6D0wGuFXhhrmhNl3miiK5HDoimdvbOnZHOedIyz9KmS2aAV2EryRtuh3GME5SaSNIwo6A9LRBSAfWruCkOjuGT+Q/LXsYWOtpyqi4XisCnDysgBmL0Ro3k1y9VH X-Received: by 10.194.121.6 with SMTP id lg6mr95608434wjb.105.1481585907788; Mon, 12 Dec 2016 15:38:27 -0800 (PST) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id a13sm37830986wma.18.2016.12.12.15.38.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 15:38:27 -0800 (PST) Subject: Re: snapbuild woes To: Andres Freund References: <20161212214227.qxspxdqqrprfvnz3@alap3.anarazel.de> <194608bf-d403-b566-3578-4439e70a8119@2ndquadrant.com> <20161212223338.bmhswrdaipttvcve@alap3.anarazel.de> Cc: PostgreSQL-development From: Petr Jelinek Message-ID: <7023017e-8b08-eaba-396c-80baf0a793c0@2ndquadrant.com> Date: Tue, 13 Dec 2016 00:38:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161212223338.bmhswrdaipttvcve@alap3.anarazel.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 12/12/16 23:33, Andres Freund wrote: > On 2016-12-12 23:27:30 +0100, Petr Jelinek wrote: >> On 12/12/16 22:42, Andres Freund wrote: >>> Hi, >>> >>> On 2016-12-10 23:10:19 +0100, Petr Jelinek wrote: >>>> Hi, >>>> First one is outright bug, which has to do with how we track running >>>> transactions. What snapbuild basically does while doing initial snapshot >>>> is read the xl_running_xacts record, store the list of running txes and >>>> then wait until they all finish. The problem with this is that >>>> xl_running_xacts does not ensure that it only logs transactions that are >>>> actually still running (to avoid locking PGPROC) so there might be xids >>>> in xl_running_xacts that already committed before it was logged. >>> >>> I don't think that's actually true? Notice how LogStandbySnapshot() >>> only releases the lock *after* the LogCurrentRunningXacts() iff >>> wal_level >= WAL_LEVEL_LOGICAL. So the explanation for the problem you >>> observed must actually be a bit more complex :( >>> >> >> Hmm, interesting, I did see the transaction commit in the WAL before the >> xl_running_xacts that contained the xid as running. I only seen it on >> production system though, didn't really manage to easily reproduce it >> locally. > > I suspect the reason for that is that RecordTransactionCommit() doesn't > conflict with ProcArrayLock in the first place - only > ProcArrayEndTransaction() does. So they're still running in the PGPROC > sense, just not the crash-recovery sense... > That looks like reasonable explanation. BTW I realized my patch needs bit more work, currently it will break the actual snapshot as it behaves same as if the xl_running_xacts was empty which is not correct AFAICS. Also if we did the approach suggested by my patch (ie using this xmin/xmax comparison) I guess we wouldn't need to hold the lock for extra time in wal_level logical anymore. That is of course unless you think it should be approached from the other side of the stream and try log correct xl_running_xacts. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, 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