Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXV8Q-0007EE-UH for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Aug 2016 15:09:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bXV8Q-0007ch-5C for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Aug 2016 15:09:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bXV8O-0007bE-96 for pgsql-hackers@postgresql.org; Wed, 10 Aug 2016 15:09:32 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bXV8K-0006p9-TM for pgsql-hackers@postgresql.org; Wed, 10 Aug 2016 15:09:31 +0000 Received: by mail-wm0-x22c.google.com with SMTP id o80so110435585wme.1 for ; Wed, 10 Aug 2016 08:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=/uLUCsvcKl9dQjjBOztEMkwQVVwEL0jkP6Z50ceQoVg=; b=O1FeP7nRHuSq55HqyzcTkB6vX6jJelZ1zdCzfW8oT5JveFHhLJYgPYa2h5dHrQNl2Z 3ptbBb4dOG2PG0g5ixsQYhlUaeDMebRJeiJy98+OUhYik/UkIlhp/AMCjpXqUh+3G0Tg PRxaROQa6XM5KA0ztfVopQn3XjvnqGIvgvfSWwFYtxjHlyxckd2EmRyvMkHU0xwOSDtV LMjUjNip07iGPZN/Hyri4Qe7wlNDILF5Qd2yCqmn00Gitg0POnwkHjH3IzZ2o9tcZujp tLseeORXbs59HWi+FtAy1316rVtxH24CqSs9/hMp435kLKbnpH34MfA7ZeC57M4/MUy1 TQ3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=/uLUCsvcKl9dQjjBOztEMkwQVVwEL0jkP6Z50ceQoVg=; b=PbGtrXXtiuWXOD1u2SLgFYJxxkVHQc7q8/qfq3bTQHZz3QjOt46C4TqAox97UTPRyj kG2HY2rc1WvjoPmsd30XQOpvaNbuWmCnPx/saob15okNvtYEQlYckT4MzakfQgWENVxs jXZObIkUh3VzFzm5bXeN24YeIsFooWXxQE74AOrr2xAJMoXgwXuqbiJJUbskmICqrha5 tlYFl2C4dRDsH9Pat4I0qTZWzXgWVBp3cDYWKcdMFKsOkCVVXr+TXP07CZu+5X0+Y6He 7b1ijQLCXg5HNsR38kg48ix/+IJLiTXA4xHBOZnUrd7mdPdEVDmOrK5iZfNgkzCFvWal MYng== X-Gm-Message-State: AEkooutBWlcfR1kH9GW3EQg/70DS8Kc/TnFiYttYc+qz7W2pIy2Pvb0y8SXYYQ/0Mgw96A== X-Received: by 10.194.142.78 with SMTP id ru14mr5276388wjb.41.1470841768049; Wed, 10 Aug 2016 08:09:28 -0700 (PDT) Received: from [192.168.1.111] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id 3sm8870771wms.1.2016.08.10.08.09.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Aug 2016 08:09:27 -0700 (PDT) Subject: Re: Proposal for CSN based snapshots To: Tom Lane References: <51B6C97B.1070000@bluegap.ch> <539AD153.9000004@vmware.com> <1409043789.2335.330.camel@jeff-desktop> <53FC6545.7000501@vmware.com> <1409116988.2335.463.camel@jeff-desktop> <53FD7D65.9040602@vmware.com> <53FD7DCC.5020005@vmware.com> <69041c5a-ec60-3c54-49d0-5df071b27f52@iki.fi> <5596.1470838147@sss.pgh.! pa.us> <79213506-4c9c-7e7a-44c6-ae94484c1159@iki.fi> <6906.1470840684@sss.pgh.pa.us> Cc: Alexander Korotkov , Simon Riggs , Robert Haas , Dilip Kumar , Jeff Davis , PostgreSQL-development , Alvaro Herrera , Greg Stark , Andres Freund , Rajeev rastogi , Markus Wanner , Ants Aasma , Bruce Momjian , obartunov , Teodor Sigaev From: Heikki Linnakangas Message-ID: <8c150c9d-6ba2-69fd-e908-ed2fc2775c05@iki.fi> Date: Wed, 10 Aug 2016 18:09:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: <6906.1470840684@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 08/10/2016 05:51 PM, Tom Lane wrote: > Heikki Linnakangas writes: >> On 08/10/2016 05:09 PM, Tom Lane wrote: >>> Uh, what? That's not the semantics we have today, and I don't see why >>> it's necessary or a good idea. Once the commit is in the WAL stream, >>> any action taken on the basis of seeing the commit must be later in >>> the WAL stream. So what's the problem? > >> I was talking about synchronous commits in the above. A synchronous >> commit is not made visible to other transactions, until the commit WAL >> record is flushed to disk. > > [ thinks for a bit... ] Oh, OK, that's because we don't treat a > transaction as committed until its clog bit is set *and* it's not > marked as running in the PGPROC array. And sync transactions will > flush WAL in between. Right. > Still, having to invent CSNs seems like a huge loss for this design. > Personally I'd give up async commit first. If we had only sync commit, > the rule could be "xact LSN less than snapshot threshold and less than > WAL flush position", and we'd not need CSNs. I know some people like > async commit, but it's there because it was easy and cheap in our old > design, not because it's the world's greatest feature and worth giving > up performance for. I don't think that's a very popular opinion (I disagree, for one). Asynchronous commits are a huge performance boost for some applications. The alternative is fsync=off, and I don't want to see more people doing that. SSDs have made the penalty of an fsync much smaller, but it's still there. Hmm. There's one more possible way this could all work. Let's have CSN == LSN, also for asynchronous commits. A snapshot is the current insert position, but also make note of the current flush position, when you take a snapshot. Now, when you use the snapshot, if you ever see an XID that committed between the snapshot's insert position and the flush position, wait for the WAL to be flushed up to the snapshot's insert position at that point. With that scheme, an asynchronous commit could return to the application without waiting for a flush, but if someone actually looks at the changes the transaction made, then that transaction would have to wait. Furthermore, we could probably skip that waiting too, if the reading transaction is also using synchronous_commit=off. That's slightly different from the current behaviour. A transaction that runs with synchronous_commit=on, and reads data that was modified by an asynchronous transaction, would take a hit. But I think that would be acceptable. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers