On Tue, Jul 12, 2011 at 05:59:01PM -0400, Alvaro Herrera wrote:
> Excerpts from Noah Misch's message of vie mar 11 12:51:14 -0300 2011:
> > On Fri, Feb 11, 2011 at 02:13:22AM -0500, Noah Misch wrote:
> > > Automated tests would go a long way toward building confidence that this
> > > patch
> > > does the right thing. Thanks to the SSI patch, we now have an in-tree
> > > test
> > > framework for testing interleaved transactions. The only thing it needs
> > > to be
> > > suitable for this work is a way to handle blocked commands. If you like,
> > > I can
> > > try to whip something up for that.
> > [off-list ACK followed]
> >
> > Here's a patch implementing that. It applies to master, with or without
> > your
> > KEY LOCK patch also applied, though the expected outputs reflect the
> > improvements from your patch. I add three isolation test specs:
> >
> > fk-contention: blocking-only test case from your blog post
> > fk-deadlock: the deadlocking test case I used during patch review
> > fk-deadlock2: Joel Jacobson's deadlocking test case
>
> Thanks for this patch. I have applied it, adjusting the expected output
> of these tests to the HEAD code. I'll adjust it when I commit the
> fklocks patch, I guess, but it seemed simpler to have it out of the way;
> besides it might end up benefitting other people who might be messing
> with the locking code.
Great. There have been a few recent patches where I would have used this
functionality to provide tests, so I'm glad to have it in.
> > I think this will work on Windows as well as pgbench does, but I haven't
> > verified that.
>
> We will find out shortly.
I see you've added a fix for the MSVC animals; thanks.
coypu failed during the run of the test due to a different session being chosen
as the deadlock victim. We can now vary deadlock_timeout to prevent this; see
attached fklocks-tests-deadlock_timeout.patch. This also makes the tests much
faster on a default postgresql.conf.
crake failed when it reported waiting on the first step of an existing isolation
test ("two-ids.spec"). I will need to look into that further.
Thanks,
nm
diff --git a/src/test/isolation/expected/fk-deadlock.out
b/src/test/isolation/expected/fk-deadlock.out
index 6b6ee16..0d86cda 100644
*** a/src/test/isolation/expected/fk-deadlock.out
--- b/src/test/isolation/expected/fk-deadlock.out
***************
*** 32,39 **** step s1i: INSERT INTO child VALUES (1, 1);
step s2i: INSERT INTO child VALUES (2, 1);
step s2u: UPDATE parent SET aux = 'baz'; <waiting ...>
step s1u: UPDATE parent SET aux = 'bar';
- step s2u: <... completed>
ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
--- 32,39 ----
step s2i: INSERT INTO child VALUES (2, 1);
step s2u: UPDATE parent SET aux = 'baz'; <waiting ...>
step s1u: UPDATE parent SET aux = 'bar';
ERROR: deadlock detected
+ step s2u: <... completed>
step s2c: COMMIT;
step s1c: COMMIT;
***************
*** 52,59 **** step s2i: INSERT INTO child VALUES (2, 1);
step s1i: INSERT INTO child VALUES (1, 1);
step s2u: UPDATE parent SET aux = 'baz'; <waiting ...>
step s1u: UPDATE parent SET aux = 'bar';
- step s2u: <... completed>
ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
--- 52,59 ----
step s1i: INSERT INTO child VALUES (1, 1);
step s2u: UPDATE parent SET aux = 'baz'; <waiting ...>
step s1u: UPDATE parent SET aux = 'bar';
ERROR: deadlock detected
+ step s2u: <... completed>
step s2c: COMMIT;
step s1c: COMMIT;
diff --git a/src/test/isolation/expected/fk-deadloindex af3ce8e..6e7f12d 100644
*** a/src/test/isolation/expected/fk-deadlock2.out
--- b/src/test/isolation/expected/fk-deadlock2.out
***************
*** 42,49 **** step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
- step s2u2: <... completed>
ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
--- 42,49 ----
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
ERROR: deadlock detected
+ step s2u2: <... completed>
step s1c: COMMIT;
step s2c: COMMIT;
***************
*** 52,59 **** step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
- step s2u2: <... completed>
ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
--- 52,59 ----
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
ERROR: deadlock detected
+ step s2u2: <... completed>
step s2c: COMMIT;
step s1c: COMMIT;
***************
*** 82,89 **** step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
- step s2u2: <... completed>
ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
--- 82,89 ----
step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
ERROR: deadlock detected
+ step s2u2: <... completed>
step s1c: COMMIT;
step s2c: COMMIT;
***************
*** 92,99 **** step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
- step s2u2: <... completed>
ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
--- 92,99 ----
step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
ERROR: deadlock detected
+ step s2u2: <... completed>
step s2c: COMMIT;
step s1c: COMMIT;
diff --git a/src/test/isolation/specs/fk-deadlock.sindex 530cf10..b533d77 100644
*** a/src/test/isolation/specs/fk-deadlock.spec
--- b/src/test/isolation/specs/fk-deadlock.spec
***************
*** 19,31 **** teardown
}
session "s1"
! setup { BEGIN; }
step "s1i" { INSERT INTO child VALUES (1, 1); }
step "s1u" { UPDATE parent SET aux = 'bar'; }
step "s1c" { COMMIT; }
session "s2"
! setup { BEGIN; }
step "s2i" { INSERT INTO child VALUES (2, 1); }
step "s2u" { UPDATE parent SET aux = 'baz'; }
step "s2c" { COMMIT; }
--- 19,31 ----
}
session "s1"
! setup { BEGIN; SET deadlock_timeout = '20ms'; }
step "s1i" { INSERT INTO child VALUES (1, 1); }
step "s1u" { UPDATE parent SET aux = 'bar'; }
step "s1c" { COMMIT; }
session "s2"
! setup { BEGIN; SET deadlock_timeout = '10s'; }
step "s2i" { INSERT INTO child VALUES (2, 1); }
step "s2u" { UPDATE parent SET aux = 'baz'; }
step "s2c" { COMMIT; }
diff --git a/src/test/isolation/specs/fk-deadlocindex 91a87d1..5653628 100644
*** a/src/test/isolation/specs/fk-deadlock2.spec
--- b/src/test/isolation/specs/fk-deadlock2.spec
***************
*** 24,36 **** teardown
}
session "s1"
! setup { BEGIN; }
step "s1u1" { UPDATE A SET Col1 = 1 WHERE AID = 1; }
step "s1u2" { UPDATE B SET Col2 = 1 WHERE BID = 2; }
step "s1c" { COMMIT; }
session "s2"
! setup { BEGIN; }
step "s2u1" { UPDATE B SET Col2 = 1 WHERE BID = 2; }
step "s2u2" { UPDATE B SET Col2 = 1 WHERE BID = 2; }
step "s2c" { COMMIT; }
--- 24,36 ----
}
session "s1"
! setup { BEGIN; SET deadlock_timeout = '20ms'; }
step "s1u1" { UPDATE A SET Col1 = 1 WHERE AID = 1; }
step "s1u2" { UPDATE B SET Col2 = 1 WHERE BID = 2; }
step "s1c" { COMMIT; }
session "s2"
! setup { BEGIN; SET deadlock_timeout = '10s'; }
step "s2u1" { UPDATE B SET Col2 = 1 WHERE BID = 2; }
step "s2u2" { UPDATE B SET Col2 = 1 WHERE BID = 2; }
step "s2c" { COMMIT; }
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers