Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5RjC-00025C-Bh for pgsql-hackers@arkaria.postgresql.org; Tue, 02 May 2017 06:56:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d5RjB-00070X-8R for pgsql-hackers@arkaria.postgresql.org; Tue, 02 May 2017 06:56:05 +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 1d5RjA-00070N-Kw for pgsql-hackers@postgresql.org; Tue, 02 May 2017 06:56:04 +0000 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d5Rj3-0005Oc-MN for pgsql-hackers@postgresql.org; Tue, 02 May 2017 06:56:03 +0000 Received: by mail-wr0-x234.google.com with SMTP id w50so73071985wrc.0 for ; Mon, 01 May 2017 23:55:57 -0700 (PDT) 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=ruvfB9GZWTjW2DIPKN10nuWhNCOzbVq3ZU1hLgb4b3E=; b=ec8FyW6bqdWzMdOvg6ourM0xpRR0DjdkadKoyETgYqbuIfTCnqugT/qdWbVinp8dtp vzJ58nlWDSvY6FJ2tmOCoiWZP5a9vx9blpT9c9OHW1ZdRYI+u9FF1FQO8lelylP2kPDH P4ay5NrB5W4ytmOVCWRciqLqmvEl3VvoZccmFpMh0JIBap3gaNUBuJlPVRmakeSp9xhL xWKnnrBePn/FzlEvBfqv3w8zi9Gb2UWJbW338lTxhB3r6N3FCStEnf0M3Q4wwreqjD11 FhAltET4eybRKgRdxu8bP4+bbC7rOZVamGJkgyLTccFCbjJ7kxx6sAcCnJh9OS8geR+L Ji/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ruvfB9GZWTjW2DIPKN10nuWhNCOzbVq3ZU1hLgb4b3E=; b=bOWsoMWGLDnGuTvy5ZDlAnDzx6tE9nowiUVE2wNHcbv3EtE4jFKqdT77KblUUGo+By FUdKGoDB0wBWx4/l1mtjLyChQrdRh0931UdJNSjfYmx+OKiJodi5utWlCP5jA+J9oqvj 3sVT6JKue9CdzcYcU2UN9cBTf2HjfdTFgvipI80GwXS2IjxOuS0u9Ge93MgeJBg+BAJk ++QvzTGc0x9fL4sHS7AXQA7VkOVkvJoxab821toSlqAIgXPVEHGmBAkuczvrtyw3a/o8 jfvJD58qoFnvvI49HIcqlHlVczhIFjz312Gxchil8vUgygAWr7xQVi11qP1T7XI7xnen AeVw== X-Gm-Message-State: AN3rC/6L/AWLIKT1MLnXxQ5qbOSt/tNMGJYX2p7Lr4xeEf2y7ZLBg9m9 vZtL+IvuCJW5MvxE X-Received: by 10.223.169.230 with SMTP id b93mr18777992wrd.196.1493708155227; Mon, 01 May 2017 23:55:55 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id f64sm1131812wmg.2.2017.05.01.23.55.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 May 2017 23:55:54 -0700 (PDT) Subject: Re: snapbuild woes To: Andres Freund References: <51f65289-54f8-2256-d107-937d662d69f1@2ndquadrant.com> <20170413002959.apytyi5lkknauauj@alap3.anarazel.de> <0d06dfc1-0bc5-c3ab-3555-24e2f275d7fa@2ndquadrant.com> <30242bc6-eca4-b7bb-670e-8d0458753a8c@2ndquadrant.com> <20170501005921.qcqd7w2njpv3av6s@alap3.anarazel.de> <20170501013529.sejtgo2acxbvq26q@alap3.anarazel.de> <209861fc-718f-0a7b-3a1d-36512865c209@2ndquadrant.com> <20170501080348.vb6mj5whdex3f7l7@alap3.anarazel.de> <20170501191419.coqbtx2jodu22ufz@alap3.anarazel.de> Cc: PostgreSQL-development , Erik Rijkers , Robert Haas , Craig Ringer From: Petr Jelinek Message-ID: Date: Tue, 2 May 2017 08:55:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170501191419.coqbtx2jodu22ufz@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 01/05/17 21:14, Andres Freund wrote: > On 2017-05-01 11:09:44 +0200, Petr Jelinek wrote: >> On 01/05/17 10:03, Andres Freund wrote: >>> On 2017-05-01 03:54:49 +0200, Petr Jelinek wrote: > >>>> But, I still think we need to restart the tracking after new >>>> xl_running_xacts. Reason for that is afaics any of the catalog snapshots >>>> that we assigned to transactions at the end of SnapBuildCommitTxn might >>>> be corrupted otherwise as they were built before we knew one of the >>>> supposedly running txes was actually already committed and that >>>> transaction might have done catalog changes. >>> >>> I'm afraid you're right. But I think this is even more complicated: The >>> argument in your version that this can only happen once, seems to also >>> be holey: Just imagine a pg_usleep(3000 * 1000000) right before >>> ProcArrayEndTransaction() and enjoy the picture. > >> Well yes, transaction can in theory have written commit/abort xlog >> record and stayed in proc for more than single xl_running_xacts write. >> But then the condition which we test that the new xl_running_xacts has >> bigger xmin than the previously tracked one's xmax would not be >> satisfied and we would not enter the relevant code path yet. So I think >> we should not be able to get any xids we didn't see. But we have to >> restart tracking from beginning (after first checking if we didn't >> already see anything that the xl_running_xacts considers as running), >> that's what my code did. > > But to get that correct, we'd have to not only track ->committed, but > also somehow maintain ->aborted, and not just for the transactions in > the original set of running transactions. That'd be fairly complicated > and large. The reason I was trying - and it's definitely not correct as > I had proposed - to use the original running_xacts record is that that > only required tracking as many transaction statuses as in the first > xl_running_xacts. Am I missing something? Aah, now I understand we talked about slightly different things, I considered the running thing to be first step towards tracking aborted txes everywhere. I am not sure if it's complicated, it would be exactly the same as committed tracking, except we'd do it only before we reach SNAPBUILD_CONSISTENT. It would be definitely larger patch I agree, but I can give it at try. If you think that adding the SNAPBUILD_BUILD_INITIAL_SNAPSHOT would be less invasive/smaller patch I am okay with doing that for PG10. I think we'll have to revisit tracking of aborted transactions in PG11 then though because of the 'snapshot too large' issue when exporting, at least I don't see any other way to fix that. > > The probabilistic tests catch the issues here fairly quickly, btw, if > you run with synchronous_commit=on, while pgbench is running, because > the WAL flushes make this more likely. Runs this query: > > SELECT account_count, teller_count, account_sum - teller_sum s > FROM > ( > SELECT count(*) account_count, SUM(abalance) account_sum > FROM pgbench_accounts > ) a, > ( > SELECT count(*) teller_count, SUM(tbalance) teller_sum > FROM pgbench_tellers > ) t > > which, for my scale, should always return: > ┌─────────┬─────┬───┐ > │ a │ t │ s │ > ├─────────┼─────┼───┤ > │ 2000000 │ 200 │ 0 │ > └─────────┴─────┴───┘ > but with my POC patch occasionally returns things like: > ┌─────────┬─────┬───────┐ > │ a │ t │ s │ > ├─────────┼─────┼───────┤ > │ 2000000 │ 212 │ 37358 │ > └─────────┴─────┴───────┘ > > which obviously shouldn't be the case. > Very nice (the test, not the failures ;)) ! -- 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