Thread: BUG #5007: could not reattach to shared memory

BUG #5007: could not reattach to shared memory

From
"Regina"
Date:
The following bug has been logged online:

Bug reference:      5007
Logged by:          Regina
Email address:      lr@pcorp.us
PostgreSQL version: 8.3.6
Operating system:   Windows 2008 Server Standard
Description:        could not reattach to shared memory
Details:

One of our clients is getting the following error in their PostgreSQL 8.3.6
logs in their ASP.NET application.  This only happens if their application
runs a long query (which they dump out to disk and disk size (ESRI
shapefiles) is generally above 70 mb or more) when this fails.

The error is below:
FATAL:  could not reattach to shared memory (key=232, addr=01DF0000): 487
%t WARNING:  worker took too long to start; cancelled

%t LOG:  could not receive data from client: Unknown winsock error 10061
%t LOG:  unexpected EOF on client connection

In these cases their .NET app returns this error
Exception of type 'System.OutOfMemoryException' was thrown

I've seen errors like this in the PostgreSQL threads and some suggestion
that this may be a bug and that there is a patch for it.  I was thinking of
upgrading them to 8.3.7 but don't see any mention of this in the release
notes to know if 8.3.7 will fix this.
I'm going to test their queries outside of their application to rule out the
application and their query as culprits.

Thanks,
Regina

Re: BUG #5007: could not reattach to shared memory

From
Craig Ringer
Date:
On Tue, 2009-08-25 at 05:44 +0000, Regina wrote:
> The following bug has been logged online:
>
> Bug reference:      5007
> Logged by:          Regina
> Email address:      lr@pcorp.us
> PostgreSQL version: 8.3.6
> Operating system:   Windows 2008 Server Standard
> Description:        could not reattach to shared memory
> Details:
>
> One of our clients is getting the following error in their PostgreSQL 8.3.6
> logs in their ASP.NET application.  This only happens if their application
> runs a long query (which they dump out to disk and disk size (ESRI
> shapefiles) is generally above 70 mb or more) when this fails.
>
> The error is below:
> FATAL:  could not reattach to shared memory (key=232, addr=01DF0000): 487
> %t WARNING:  worker took too long to start; cancelled

Search the -general mailing list archives for "reattach to shared
memory". The issue has been around for a while but until recently nobody
could reproduce it well enough to isolate it and test possible fixed.
You'll see some recent discussion and a proposed patch.

Try upgrading to the latest version in the 8.3 series. If you still see
the problem please follow up here, or try the patch for the issuye
proposed on the pgsql-general list.

> In these cases their .NET app returns this error
> Exception of type 'System.OutOfMemoryException' was thrown

That's probably a bug in their application caused by failure to properly
handle a connection problem.


--
Craig Ringer

Re: BUG #5007: could not reattach to shared memory

From
Magnus Hagander
Date:
On Tuesday, August 25, 2009, Craig Ringer <craig@postnewspapers.com.au> wro=
te:
> On Tue, 2009-08-25 at 05:44 +0000, Regina wrote:
>> The following bug has been logged online:
>>
>> Bug reference: =A0 =A0 =A05007
>> Logged by: =A0 =A0 =A0 =A0 =A0Regina
>> Email address: =A0 =A0 =A0lr@pcorp.us
>> PostgreSQL version: 8.3.6
>> Operating system: =A0 Windows 2008 Server Standard
>> Description: =A0 =A0 =A0 =A0could not reattach to shared memory
>> Details:
>>
>> One of our clients is getting the following error in their PostgreSQL 8.=
3.6
>> logs in their http://ASP.NET application. =A0This only happens if their =
application
>> runs a long query (which they dump out to disk and disk size (ESRI
>> shapefiles) is generally above 70 mb or more) when this fails.
>>
>> The error is below:
>> FATAL: =A0could not reattach to shared memory (key=3D232, addr=3D01DF000=
0): 487
>> %t WARNING: =A0worker took too long to start; cancelled
>
> Search the -general mailing list archives for "reattach to shared
> memory". The issue has been around for a while but until recently nobody
> could reproduce it well enough to isolate it and test possible fixed.
> You'll see some recent discussion and a proposed patch.
>
> Try upgrading to the latest version in the 8.3 series. If you still see
> the problem please follow up here, or try the patch for the issuye
> proposed on the pgsql-general list.

The probable fix is not in a released version - it will be in the next
one. Please try to upgrade to the latest and then replace postgres.exe
with the one from http://blog.hagander.net ad let us know if it works
in your situation.

>
>> In these cases their .NET app returns this error
>> Exception of type 'System.OutOfMemoryException' was thrown
>
> That's probably a bug in their application caused by failure to properly
> handle a connection problem.

Yes, or possibly npgsql having the bug, though I haven't heard of it
there. The stacktrace should probably tell you where - if not, a
memory dump with the debugger.

/Magnus


--=20
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

Re: BUG #5007: could not reattach to shared memory

From
"Paragon Corporation"
Date:
Craig,

Thanks. I assume you mean this one?

http://archives.postgresql.org/pgsql-hackers/2009-07/msg01419.php

I'll check with them to see if its okay if we give this a try.

Thanks,
Regina

-----Original Message-----
From: Craig Ringer [mailto:craig@postnewspapers.com.au]
Sent: Tuesday, August 25, 2009 1:56 AM
To: Regina
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #5007: could not reattach to shared memory

On Tue, 2009-08-25 at 05:44 +0000, Regina wrote:
> The following bug has been logged online:
>
> Bug reference:      5007
> Logged by:          Regina
> Email address:      lr@pcorp.us
> PostgreSQL version: 8.3.6
> Operating system:   Windows 2008 Server Standard
> Description:        could not reattach to shared memory
> Details:
>
> One of our clients is getting the following error in their PostgreSQL
> 8.3.6 logs in their ASP.NET application.  This only happens if their
> application runs a long query (which they dump out to disk and disk
> size (ESRI
> shapefiles) is generally above 70 mb or more) when this fails.
>
> The error is below:
> FATAL:  could not reattach to shared memory (key=232, addr=01DF0000):
> 487 %t WARNING:  worker took too long to start; cancelled

Search the -general mailing list archives for "reattach to shared memory".
The issue has been around for a while but until recently nobody could
reproduce it well enough to isolate it and test possible fixed.
You'll see some recent discussion and a proposed patch.

Try upgrading to the latest version in the 8.3 series. If you still see the
problem please follow up here, or try the patch for the issuye proposed on
the pgsql-general list.

> In these cases their .NET app returns this error Exception of type
> 'System.OutOfMemoryException' was thrown

That's probably a bug in their application caused by failure to properly
handle a connection problem.


--
Craig Ringer

Re: BUG #5007: could not reattach to shared memory

From
"Paragon Corporation"
Date:
Magnus and Craig,

Thanks for the help.  We upgraded and also put in the patch and things have
been running for about a week now with all that in place. The reattach
memory problem seems to have been cured by the patch.

Unfortunately the System.OutOfMemory from .NET and the LOG:  could not
receive data from client: Unknown winsock error 10061 in postgresql logs
still persist.  I suspect the log error is just because the .NET app dies
and abruptly disconnects its connection to PostgreSQL when it runs out of
memory.

I think I have ruled out PostgreSQL as the culprit here since I was able to
successfully run the same query and dump out to shape with pgsql2shp command
line.  Looking at the .NET code, I think its just because they are trying to
load the large query data into a DataSet object before dumping to shape file
so can't really blame npgsql for that either.  I think they'll just have to
switch to use a Datareader instead or do a Process call to call pgsql2shp.

Thanks,
Regina

-----Original Message-----
From: Magnus Hagander [mailto:magnus@hagander.net]
Sent: Tuesday, August 25, 2009 2:18 AM
To: Craig Ringer
Cc: Regina; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #5007: could not reattach to shared memory

On Tuesday, August 25, 2009, Craig Ringer <craig@postnewspapers.com.au>
wrote:
> On Tue, 2009-08-25 at 05:44 +0000, Regina wrote:
>> The following bug has been logged online:
>>
>> Bug reference: =A0 =A0 =A05007
>> Logged by: =A0 =A0 =A0 =A0 =A0Regina
>> Email address: =A0 =A0 =A0lr@pcorp.us
>> PostgreSQL version: 8.3.6
>> Operating system: =A0 Windows 2008 Server Standard
>> Description: =A0 =A0 =A0 =A0could not reattach to shared memory
>> Details:
>>
>> One of our clients is getting the following error in their PostgreSQL
>> 8.3.6 logs in their http://ASP.NET application. =A0This only happens if=
=20
>> their application runs a long query (which they dump out to disk and=20
>> disk size (ESRI
>> shapefiles) is generally above 70 mb or more) when this fails.
>>
>> The error is below:
>> FATAL: =A0could not reattach to shared memory (key=3D232, addr=3D01DF000=
0):=20
>> 487 %t WARNING: =A0worker took too long to start; cancelled
>
> Search the -general mailing list archives for "reattach to shared=20
> memory". The issue has been around for a while but until recently=20
> nobody could reproduce it well enough to isolate it and test possible
fixed.
> You'll see some recent discussion and a proposed patch.
>
> Try upgrading to the latest version in the 8.3 series. If you still=20
> see the problem please follow up here, or try the patch for the issuye=20
> proposed on the pgsql-general list.

The probable fix is not in a released version - it will be in the next one.
Please try to upgrade to the latest and then replace postgres.exe with the
one from http://blog.hagander.net ad let us know if it works in your
situation.

>
>> In these cases their .NET app returns this error Exception of type=20
>> 'System.OutOfMemoryException' was thrown
>
> That's probably a bug in their application caused by failure to=20
> properly handle a connection problem.

Yes, or possibly npgsql having the bug, though I haven't heard of it there.
The stacktrace should probably tell you where - if not, a memory dump with
the debugger.

/Magnus


--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/