From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Peter Geoghegan <pg(at)heroku(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Failure while inserting parent tuple to B-tree is not fun |
Date: | 2014-01-27 18:58:57 |
Message-ID: | 52E6AC71.9010905@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 01/23/2014 11:36 PM, Peter Geoghegan wrote:
> That's all I have for now. I've written plenty of notes, and will work
> back through other points of possible concern. I don't suppose you
> have any testing infrastructure that you could publish?
Okay, promise not to laugh. I did write a bunch of hacks, to generate
graphviz .dot files from the btree pages, and render them into pictures.
It consist of multiple parts, all in the attached tarball. Here's how to
use it:
After installing all the parts (instructions below), launch the
btree-snapshot.sh script. It will poll every seconds, and generate a
.dot graph out of an index called 'i_foo'. It compares the snapshot with
the previous one, and if it differs, it generates a new .png file from
it under /tmp.
With that, you can get a slideshow of how the index changes, when you
execute commands that modify it. However, because it only polls once per
second, you'll have to insert some sleeps into the code you're testing,
so that the script can catch the changes in action. See attached
nbtinsert-sleeps.patch.
For example:
create table foo (t text);
create index i_foo on foo (t);
-- launch btree-snapshot.sh in another terminal
insert into foo select 'aaa' || g from generate_series(1, 10000) g;
Once that finishes, the btree-snapshot.sh script should've generated a
bunch of .png files in /tmp/:
~$ ls /tmp/*.png
/tmp/g1.png /tmp/g3.png /tmp/g5.png /tmp/g7.png
/tmp/g2.png /tmp/g4.png /tmp/g6.png /tmp/g8.png
Each shows the structure of the tree, after something changed. It shows
how a page is split, and then the downlink to it is inserted into the
parent as a separate step. I've attached those files in
graphs-example.tar. I view them with "eog /tmp/g*.png", it lets you flip
through the pictures easily.
To install this hack, do the following:
1. Patch pageinspect contrib module to not lock the pages while it looks
at them. (otherwise you won't be able to snapshot transient states where
a backend is holding pages locked)
2. Install extensions pageinspect and pgstattuple:
create extension pageinspect;
create extension pgstattuple;
3. Run btree-graphviz2.sql. It creates a bunch of functions.
That's it. Have fun :-)
- Heikki
Attachment | Content-Type | Size |
---|---|---|
btree-graph-hack.tar | application/x-tar | 10.0 KB |
nbtinsert-sleeps.patch | text/x-diff | 605 bytes |
graphs-example.tar | application/x-tar | 70.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2014-01-27 19:20:23 | Re: [PATCH] Use MAP_HUGETLB where supported (v3) |
Previous Message | Peter Geoghegan | 2014-01-27 18:54:13 | Re: Failure while inserting parent tuple to B-tree is not fun |