Re: In-place updates and serializable transactions

From: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
To: Kevin Grittner <kgrittn(at)gmail(dot)com>
Cc: joshua(dot)yanovski(at)gmail(dot)com, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql(at)j-davis(dot)com, joe(dot)conway(at)crunchydata(dot)com
Subject: Re: In-place updates and serializable transactions
Date: 2018-11-15 09:03:12
Message-ID: CAGz5QCLQeXextUiBkF8vcffT=Y-083kfoSZCw54gDXmvS7iTpg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 15, 2018 at 3:09 AM Kevin Grittner <kgrittn(at)gmail(dot)com> wrote:
>
> On Wed, Nov 14, 2018 at 5:43 AM Joshua Yanovski
> <joshua(dot)yanovski(at)gmail(dot)com> wrote:
>
> > This is only a personal anecdote, but from my own experience with serializability, this sort of blind update isn't often contended in realistic workloads.
>
> > So, if this only affects transactions with blind updates, I doubt it will cause much pain in real workloads (even though it might look bad in benchmarks which include a mix of blind writes and rmw operations). Particularly if it only happens if you explicitly opt into zheap storage.
>
> I agree with all of that, but will be very interested in what
> failures, if any, kick out from the "isolation" test set when all
> tables are created using zheap. I added all the common failure
> patterns I had seen to that set, and other have filled in some corner
> cases I missed since then, so if everything there passes I would not
> worry about it at all. If we do see some failures, we can take
> another look to see whether any action is needed.
Thanks Kevin for your explanation. The isolation test suits are really
helpful for testing serializable test scenarios for zheap.

The test multiple-row-versions is failing because of the
above-discussed scenario. I've attached the regression diff file and
the result output file for the same. Here is a brief summary of the
test w.r.t. heap:

Step 1: T1-> BEGIN; Read FROM t where id=1000000;
Step 2: T2-> BEGIN; UPDATE t where id=1000000; COMMIT; (creates T1->T2)
Step 3: T3-> BEGIN; UPDATE t where id=1000000; Read FROM t where id=500000;
Step 4: T4-> BEGIN; UPDATE t where id= 500000; Read FROM t where id=1;
COMMIT; (creates T3->T4)
Step 5: T3-> COMMIT;
Step 6: T1-> UPDATE t where id=1; COMMIT; (creates T4->T1,)

At step 6, when the update statement is executed, T1 is rolled back
because of T3->T4->T1.

But for zheap, step 3 also creates a dependency T1->T3 because of
in-place update. When T4 commits in step 4, it marks T3 as doomed
because of T1 --> T3 --> T4. Hence, in step 5, T3 is rolled back.

--
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
multiple-row-versions.out application/octet-stream 859 bytes
regression.diffs application/octet-stream 690 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2018-11-15 09:12:38 Re: [PATCH] XLogReadRecord returns pointer to currently read page
Previous Message Alvaro Herrera 2018-11-15 08:59:36 Re: reloption to prevent VACUUM from truncating empty pages at the end of relation