pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Modify the isolation tester so that multiple sessions can wait.
9+ messages / 6 participants
[nested] [flat]

* pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-02-11 13:36  Robert Haas <rhaas@postgresql.org>
  0 siblings, 1 reply; 9+ messages in thread

From: Robert Haas @ 2016-02-11 13:36 UTC (permalink / raw)
  To: pgsql-committers

Modify the isolation tester so that multiple sessions can wait.

This allows testing of deadlock scenarios.  Scenarios that would
previously have been considered invalid are now simply taken as a
scenario in which more than one backend will wait.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/38f8bdcac4982215beb9f65a19debecaf22fd470

Modified Files
--------------
src/test/isolation/README            |   9 +-
src/test/isolation/isolationtester.c | 330 ++++++++++++++++++++---------------
2 files changed, 194 insertions(+), 145 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-04-27 17:51  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Robert Haas <rhaas@postgresql.org>
  0 siblings, 1 reply; 9+ messages in thread

From: Alvaro Herrera @ 2016-04-27 17:51 UTC (permalink / raw)
  To: Robert Haas <rhaas@postgresql.org>; +Cc: pgsql-hackers@postgresql.org; Mikael Kjellström <mikael.kjellstrom@gmail.com>

Robert Haas wrote:
> Modify the isolation tester so that multiple sessions can wait.

Mikael was kind enough to set up an OpenBSD 5.9 buildfarm member, and
it's been failing in isolationtester.  (I kindly accepted my suggestion
to put it to run even though it is failing so that we could look at the
logs).  I think this commit is the problem; see the backtrace he sent me
on private email.

#0  0x00001e18c62af87a in thrkill () at <stdin>:2
2       <stdin>: No such file or directory.
        in <stdin>
(gdb) bt
#0  0x00001e18c62af87a in thrkill () at <stdin>:2
#1  0x00001e18c62aaf39 in *_libc_abort () at
/usr/src/lib/libc/stdlib/abort.c:52
#2  0x00001e18c62a7838 in *_libc_memcpy (dst0=0x0, src0=0x6, length=0) at
/usr/src/lib/libc/string/memcpy.c:65
#3  0x00001e16a7904a7e in run_permutation (testspec=0x1e16a7d08b20,
nsteps=11, steps=Variable "steps" is not available.
) at isolationtester.c:617
#4  0x00001e16a7904d7c in run_testspec (testspec=0x1e16a7d08b20) at
isolationtester.c:369
#5  0x00001e16a79053ce in main (argc=Variable "argc" is not available.
) at isolationtester.c:251

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, 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



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-04-27 18:53  Robert Haas <robertmhaas@gmail.com>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Robert Haas @ 2016-04-27 18:53 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>; Mikael Kjellström <mikael.kjellstrom@gmail.com>

On Wed, Apr 27, 2016 at 1:51 PM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Robert Haas wrote:
>> Modify the isolation tester so that multiple sessions can wait.
>
> Mikael was kind enough to set up an OpenBSD 5.9 buildfarm member, and
> it's been failing in isolationtester.  (I kindly accepted my suggestion
> to put it to run even though it is failing so that we could look at the
> logs).  I think this commit is the problem; see the backtrace he sent me
> on private email.
>
> #0  0x00001e18c62af87a in thrkill () at <stdin>:2
> 2       <stdin>: No such file or directory.
>         in <stdin>
> (gdb) bt
> #0  0x00001e18c62af87a in thrkill () at <stdin>:2
> #1  0x00001e18c62aaf39 in *_libc_abort () at
> /usr/src/lib/libc/stdlib/abort.c:52
> #2  0x00001e18c62a7838 in *_libc_memcpy (dst0=0x0, src0=0x6, length=0) at
> /usr/src/lib/libc/string/memcpy.c:65
> #3  0x00001e16a7904a7e in run_permutation (testspec=0x1e16a7d08b20,
> nsteps=11, steps=Variable "steps" is not available.
> ) at isolationtester.c:617
> #4  0x00001e16a7904d7c in run_testspec (testspec=0x1e16a7d08b20) at
> isolationtester.c:369
> #5  0x00001e16a79053ce in main (argc=Variable "argc" is not available.
> ) at isolationtester.c:251

That looks like malloc() returned NULL.  I noticed when writing that
patch that isolationtester has never had any checks for malloc
returning NULL, which is bad, and probably worth fixing, but I didn't
choose to stop and fix it at that time.

I don't know off-hand why you see that problem starting at this commit
and not before, or why it doesn't show up on other machines.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-04-27 19:02  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Alvaro Herrera @ 2016-04-27 19:02 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>; Mikael Kjellström <mikael.kjellstrom@gmail.com>

Robert Haas wrote:

> That looks like malloc() returned NULL.  I noticed when writing that
> patch that isolationtester has never had any checks for malloc
> returning NULL, which is bad, and probably worth fixing, but I didn't
> choose to stop and fix it at that time.

I didn't actually check closely but I wondered whether the pointer
arithmetic is actually correct.  Note that the memcpy length is zero.
I doubt malloc returning null is the problem; how could it happen
exactly at the same spot every time the suite has run?

> I don't know off-hand why you see that problem starting at this commit
> and not before, or why it doesn't show up on other machines.

Perhaps it's only a problem for OpenBSD's libc and not for glibc which
is the most common.  The only other openbsd machine in buildfarm doesn't
run the isolation tests.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, 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



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-04-27 20:46  Thomas Munro <thomas.munro@enterprisedb.com>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Thomas Munro @ 2016-04-27 20:46 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>; Mikael Kjellström <mikael.kjellstrom@gmail.com>

On Thu, Apr 28, 2016 at 7:02 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Robert Haas wrote:
>
>> That looks like malloc() returned NULL.  I noticed when writing that
>> patch that isolationtester has never had any checks for malloc
>> returning NULL, which is bad, and probably worth fixing, but I didn't
>> choose to stop and fix it at that time.
>
> I didn't actually check closely but I wondered whether the pointer
> arithmetic is actually correct.  Note that the memcpy length is zero.
> I doubt malloc returning null is the problem; how could it happen
> exactly at the same spot every time the suite has run?
>
>> I don't know off-hand why you see that problem starting at this commit
>> and not before, or why it doesn't show up on other machines.
>
> Perhaps it's only a problem for OpenBSD's libc and not for glibc which
> is the most common.  The only other openbsd machine in buildfarm doesn't
> run the isolation tests.

Also happens on OpenBSD 5.8.  Isn't this a classic case where memmove
is called for?  Replacing the memcpy at line 617 with memmove makes
the tests run successfully, but at first glance the other two
instances of memcpy in run_permutation should also be changed to
memmove, no?

-- 
Thomas Munro
http://www.enterprisedb.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-04-27 21:54  Thomas Munro <thomas.munro@enterprisedb.com>
  parent: Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Thomas Munro @ 2016-04-27 21:54 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>; Mikael Kjellström <mikael.kjellstrom@gmail.com>

On Thu, Apr 28, 2016 at 8:46 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Thu, Apr 28, 2016 at 7:02 AM, Alvaro Herrera
> <alvherre@2ndquadrant.com> wrote:
>> Robert Haas wrote:
>>
>>> That looks like malloc() returned NULL.  I noticed when writing that
>>> patch that isolationtester has never had any checks for malloc
>>> returning NULL, which is bad, and probably worth fixing, but I didn't
>>> choose to stop and fix it at that time.
>>
>> I didn't actually check closely but I wondered whether the pointer
>> arithmetic is actually correct.  Note that the memcpy length is zero.
>> I doubt malloc returning null is the problem; how could it happen
>> exactly at the same spot every time the suite has run?
>>
>>> I don't know off-hand why you see that problem starting at this commit
>>> and not before, or why it doesn't show up on other machines.
>>
>> Perhaps it's only a problem for OpenBSD's libc and not for glibc which
>> is the most common.  The only other openbsd machine in buildfarm doesn't
>> run the isolation tests.
>
> Also happens on OpenBSD 5.8.  Isn't this a classic case where memmove
> is called for?  Replacing the memcpy at line 617 with memmove makes
> the tests run successfully, but at first glance the other two
> instances of memcpy in run_permutation should also be changed to
> memmove, no?

That abort at memcpy.c:65 is indeed a check for overlapping regions:

http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/memcpy.c?rev=1.2&content-type=text/...

That leaves the question of why the backtrace shows arguments that
wouldn't trigger it (for example memcpy exits early for length == 0).
But it appears that those stack arguments are mangled by the time gdb
dumps them, like this:

#include <string.h>
int main(int argc, char *argv[])
{
  char buffer[] = "hello world";
  memcpy(&buffer[0], &buffer[1], 2);
  return 0;
}

#0  0x00000bce27eab90a in kill () at <stdin>:2
#1  0x00000bce27ee5b19 in abort () at /usr/src/lib/libc/stdlib/abort.c:53
#2  0x00000bce27ebcde8 in memcpy (dst0=0xf7ec5, src0=0x6, length=0) at
/usr/src/lib/libc/string/memcpy.c:65
#3  0x00000bcb5fc00c7a in main (argc=1, argv=0x7f7fffff6818) at foo.c:6

Suggested patch attached.

-- 
Thomas Munro
http://www.enterprisedb.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

memmove.patch (application/octet-stream, 1.3K) download diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index 2969ce9..908a7ce 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -554,8 +554,8 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps) /* Remove that step from the waiting[] array. */ if (w + 1 < nwaiting) - memcpy(&waiting[w], &waiting[w + 1], - (nwaiting - (w + 1)) * sizeof(Step *)); + memmove(&waiting[w], &waiting[w + 1], + (nwaiting - (w + 1)) * sizeof(Step *)); nwaiting--; break; @@ -582,8 +582,8 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps) /* This one finished, too! */ errorstep[nerrorstep++] = waiting[w]; if (w + 1 < nwaiting) - memcpy(&waiting[w], &waiting[w + 1], - (nwaiting - (w + 1)) * sizeof(Step *)); + memmove(&waiting[w], &waiting[w + 1], + (nwaiting - (w + 1)) * sizeof(Step *)); nwaiting--; } } @@ -614,8 +614,8 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps) { errorstep[nerrorstep++] = waiting[w]; if (w + 1 < nwaiting) - memcpy(&waiting[w], &waiting[w + 1], - (nwaiting - (w + 1)) * sizeof(Step *)); + memmove(&waiting[w], &waiting[w + 1], + (nwaiting - (w + 1)) * sizeof(Step *)); nwaiting--; } }
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-04-27 22:15  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2016-04-27 22:15 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Robert Haas <robertmhaas@gmail.com>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>; Mikael Kjellström <mikael.kjellstrom@gmail.com>

Thomas Munro <thomas.munro@enterprisedb.com> writes:
>> Also happens on OpenBSD 5.8.  Isn't this a classic case where memmove
>> is called for?  Replacing the memcpy at line 617 with memmove makes
>> the tests run successfully, but at first glance the other two
>> instances of memcpy in run_permutation should also be changed to
>> memmove, no?

Yeah, that's clearly busted.  Surprising that it has not failed on
any other platforms.

> Suggested patch attached.

Will push in a moment.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-04-27 22:44  Mikael Kjellström <mikael.kjellstrom@mksoft.nu>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Mikael Kjellström @ 2016-04-27 22:44 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Robert Haas <robertmhaas@gmail.com>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>; Mikael Kjellström <mikael.kjellstrom@gmail.com>


On 2016-04-28 00:15, Tom Lane wrote:
> Thomas Munro <thomas.munro@enterprisedb.com> writes:
>>> Also happens on OpenBSD 5.8.  Isn't this a classic case where memmove
>>> is called for?  Replacing the memcpy at line 617 with memmove makes
>>> the tests run successfully, but at first glance the other two
>>> instances of memcpy in run_permutation should also be changed to
>>> memmove, no?
>
> Yeah, that's clearly busted.  Surprising that it has not failed on
> any other platforms.
>
>> Suggested patch attached.
>
> Will push in a moment.

And that seems to have done the trick.  I started a manual run of HEAD 
on curculio and now it's green on the build farm.

Thanks!

/Mikael


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait.
@ 2016-04-27 22:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Mikael Kjellström <mikael.kjellstrom@mksoft.nu>
  0 siblings, 0 replies; 9+ messages in thread

From: Tom Lane @ 2016-04-27 22:50 UTC (permalink / raw)
  To: Mikael Kjellström <mikael.kjellstrom@mksoft.nu>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Alvaro Herrera <alvherre@2ndquadrant.com>; Robert Haas <robertmhaas@gmail.com>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>; Mikael Kjellström <mikael.kjellstrom@gmail.com>

=?UTF-8?Q?Mikael_Kjellstr=c3=b6m?= <mikael.kjellstrom@mksoft.nu> writes:
> And that seems to have done the trick.  I started a manual run of HEAD 
> on curculio and now it's green on the build farm.

> Thanks!

Thank *you*, for putting up a buildfarm member that caught this bug.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2016-04-27 22:50 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-02-11 13:36 pgsql: Modify the isolation tester so that multiple sessions can wait. Robert Haas <rhaas@postgresql.org>
2016-04-27 17:51 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-04-27 18:53   ` Robert Haas <robertmhaas@gmail.com>
2016-04-27 19:02     ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-04-27 20:46       ` Thomas Munro <thomas.munro@enterprisedb.com>
2016-04-27 21:54         ` Thomas Munro <thomas.munro@enterprisedb.com>
2016-04-27 22:15           ` Tom Lane <tgl@sss.pgh.pa.us>
2016-04-27 22:44             ` Mikael Kjellström <mikael.kjellstrom@mksoft.nu>
2016-04-27 22:50               ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox