Lists: | pgsql-hackers |
---|
From: | "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | snapshot leak and core dump with serializable transactions |
Date: | 2008-12-03 12:20:15 |
Message-ID: | 2e78013d0812030420ia173efas6a9ede2128b26908@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
The following test flashes snapshot leak warning and subsequently dumps
core. Though this looks very similar to other bug report, this is a
different issue.
postgres=# BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE ;
BEGIN
postgres=# SAVEPOINT A;
SAVEPOINT
postgres=# SELECT count(*) from pg_class;
count
-------
227
(1 row)
postgres=# RELEASE SAVEPOINT A;
WARNING: Snapshot reference leak: Snapshot 0x9e3e4d4 still referenced
RELEASE
postgres=# SELECT count(*) from pg_class;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>
I looked at this briefly and ISTM that there are couple of issues here:
1. Since "SAVEPOINT A" is the first statement in the transaction, a
subtransaction is started and CurrentResourceOwner is set to the resource
owner of the subtransaction. Later when serializable snapshot is taken, its
recorded in the subtransaction resource owner. Obviously, when the
subtransaction commits, it complains about the snapshot leak because the
serializable snapshot is not yet unregistered.
So I tried to ensure that the serializable snapshot is always recorded in
the TopTransactionResourceOwner. It solved the above issue, but there is
still a core dump when the top transaction is committed. That leads to the
second issue.
2. In CommitTransaction(), I think we should call AtEOXact_Snapshot *before*
releasing the resource owners. Otherwise, ResourceOwnerReleaseInternal
complains about snapshot leak and then forcefully unregisters the snapshot.
Later when AtEOXact_Snapshot is called, it again tries to unregister the
serializable snapshot and assertion fails.
The attached patch fixes these issues.
Thanks,
Pavan
--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com
Attachment | Content-Type | Size |
---|---|---|
snapshot-leak.patch | text/x-patch | 2.1 KB |
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-03 12:52:32 |
Message-ID: | 20081203125232.GB3968@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Pavan Deolasee escribió:
> 2. In CommitTransaction(), I think we should call AtEOXact_Snapshot *before*
> releasing the resource owners. Otherwise, ResourceOwnerReleaseInternal
> complains about snapshot leak and then forcefully unregisters the snapshot.
> Later when AtEOXact_Snapshot is called, it again tries to unregister the
> serializable snapshot and assertion fails.
Hmm, I've been wondering if we can get away with not having
AtEOXact_Snapshot at all.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-03 14:12:43 |
Message-ID: | 6865.1228313563@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
"Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com> writes:
> 2. In CommitTransaction(), I think we should call AtEOXact_Snapshot *before*
> releasing the resource owners.
That's absolutely wrong. It'll complain about whatever snapshots the
owners still hold.
regards, tom lane
From: | "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-03 17:07:53 |
Message-ID: | 2e78013d0812030907ob9cc327t1131997770308a30@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Dec 3, 2008 at 7:42 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>
> That's absolutely wrong. It'll complain about whatever snapshots the
> owners still hold.
>
>
You must be right; I don't understand that code much. But don't we expect
the snapshots to be cleanly released at that point and if not we flash
warnings anyways ? AtEOXact_Snapshot only unregisters the serialized
snapshot which otherwise release resource owner will complain about.
Thanks,
Pavan
--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-03 19:32:18 |
Message-ID: | 20081203193218.GJ3968@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Pavan Deolasee escribió:
> On Wed, Dec 3, 2008 at 7:42 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> > That's absolutely wrong. It'll complain about whatever snapshots the
> > owners still hold.
>
> You must be right; I don't understand that code much. But don't we expect
> the snapshots to be cleanly released at that point and if not we flash
> warnings anyways ? AtEOXact_Snapshot only unregisters the serialized
> snapshot which otherwise release resource owner will complain about.
Yeah, we need two "at-commit" routines, one of which needs to be called
early. I'm prepping a patch.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-03 19:45:01 |
Message-ID: | 20081203194501.GK3968@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Alvaro Herrera escribió:
> Yeah, we need two "at-commit" routines, one of which needs to be called
> early. I'm prepping a patch.
Here it is ... the large object patch is also included. I've created
new functions to specify the resource owner to register a snapshot in;
now that there are two callers, it seems likely that there will be more
in the future.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Attachment | Content-Type | Size |
---|---|---|
lobj-snapshot-4.patch | text/x-diff | 8.9 KB |
From: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
Cc: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-03 20:20:48 |
Message-ID: | 4936EA20.4070300@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Alvaro Herrera wrote:
> Alvaro Herrera escribió:
>
>> Yeah, we need two "at-commit" routines, one of which needs to be called
>> early. I'm prepping a patch.
>
> Here it is ... the large object patch is also included. I've created
> new functions to specify the resource owner to register a snapshot in;
> now that there are two callers, it seems likely that there will be more
> in the future.
I'm surprised you implemented RegisterSnapshotOnOwner by switching
CurrentResourceOwner and calling RegisterSnapshot, rather than
implementing RegisterSnapshot by calling RegisterSnapshotOnOwner(...,
CurrentResourceOwner).
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
Cc: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-03 20:55:41 |
Message-ID: | 20081203205541.GC18595@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Heikki Linnakangas escribió:
> I'm surprised you implemented RegisterSnapshotOnOwner by switching
> CurrentResourceOwner and calling RegisterSnapshot, rather than
> implementing RegisterSnapshot by calling RegisterSnapshotOnOwner(...,
> CurrentResourceOwner).
Yeah, that was plenty silly. Updated patch attached.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Attachment | Content-Type | Size |
---|---|---|
lobj-snapshot-5.patch | text/x-diff | 10.0 KB |
From: | "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com> |
---|---|
To: | "Alvaro Herrera" <alvherre(at)commandprompt(dot)com> |
Cc: | "Heikki Linnakangas" <heikki(dot)linnakangas(at)enterprisedb(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-04 12:48:20 |
Message-ID: | 2e78013d0812040448n25f4feu66c0c626021ff028@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Dec 4, 2008 at 2:25 AM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com>wrote:
>
>
> Yeah, that was plenty silly. Updated patch attached.
>
>
Looks good me to, except for this warning:
snapmgr.c: In function 'RegisterSnapshot':
snapmgr.c:356: warning: unused variable 'snap'
Thanks,
Pavan
--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> |
Cc: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: snapshot leak and core dump with serializable transactions |
Date: | 2008-12-04 14:51:28 |
Message-ID: | 20081204145128.GF4106@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Pavan Deolasee escribió:
> On Thu, Dec 4, 2008 at 2:25 AM, Alvaro Herrera
> <alvherre(at)commandprompt(dot)com>wrote:
>
> > Yeah, that was plenty silly. Updated patch attached.
>
> Looks good me to, except for this warning:
Applied. Many thanks for the exhaustive testing.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.