From: Антон Степаненко <zlobnynigga@yandex.ru>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: Kevin Grittner <kevin.grittner@wicourts.gov>
Cc: pgsql-bugs@postgresql.org
Subject: Re: could not read block XXXXX in file "base/YYYYY/ZZZZZZ": read only 160 of 8192 bytes
Date: Fri, 17 Jun 2011 23:49:01 +0400
Message-ID: <56961308340142@web152.yandex.ru> (raw)
In-Reply-To: <BANLkTim0hL_VkkU7=ozYzRP5+Ruw-BcDuQ@mail.gmail.com>
References: <1208551308255001@web137.yandex.ru>
<4DFA2130020000250003E76A@gw.wicourts.gov>
<438511308318660@web144.yandex.ru>
<4DFB32F4020000250003E7E2@gw.wicourts.gov>
<BANLkTin8otck1rxoGcBE1wi8PZ1dEt-9fA@mail.gmail.com>
<1202541308329125@web105.yandex.ru>
<BANLkTim0hL_VkkU7=ozYzRP5+Ruw-BcDuQ@mail.gmail.com>
17.06.2011, 21:24, "Merlin Moncure" <mmoncure@gmail.com>:
> 2011/6/17 Антон Степаненко <zlobnynigga@yandex.ru>;:
>
>> 17.06.2011, 20:19, "Merlin Moncure" <mmoncure@gmail.com>;:
>>> On Fri, Jun 17, 2011 at 10:56 AM, Kevin Grittner
>>> <Kevin.Grittner@wicourts.gov>;; wrote:
>>>>> I still do not believe that this is hardware problem.
>>>> How would an application cause a bus error?
>>> unaligned memory access on risc maybe? what's this running on?
>>>
>>> merlin
>> *****:~$ cat /proc/cpuinfo
>> processor : 0
>> ....
>> processor : 23
>> vendor_id : GenuineIntel
>> cpu family : 6
>> model : 44
>> model name : Intel(R) Xeon(R) CPU E5645 @ 2.40GHz
>
> hm, I'm wondering if this
> (http://us.generation-nt.com/bug-626451-linux-image-mremap-returns-useless-pages-moving-anonymous-sha...)
> has anything to do with your problem.
>
> merlin
Thank you very much, very interesting link. I've compiled it under my ubuntu lucid - it really causes sigbus. But when compiled under CentOS 2.6.18 - it makes the same. So I am not sure that this is a bug.
And event if it is - why it occurs only when buffers are set to 12Gb and filled...
I've read some sources of postgresql, e.g. /src/backend/storage/smgr/md.c:
void
mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
char *buffer)
{
..
if (nbytes != BLCKSZ)
{
if (nbytes < 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not read block %u in file \"%s\": %m",
blocknum, FilePathName(v->mdfd_vfd))));
/*
* Short read: we are at or past EOF, or we read a partial block at
* EOF. Normally this is an error; upper levels should never try to
* read a nonexistent block. However, if zero_damaged_pages is ON or
* we are InRecovery, we should instead return zeroes without
* complaining. This allows, for example, the case of trying to
* update a block that was later truncated away.
*/
if (zero_damaged_pages || InRecovery)
MemSet(buffer, 0, BLCKSZ);
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
errmsg("could not read block %u in file \"%s\": read only %d of %d bytes",
blocknum, FilePathName(v->mdfd_vfd),
nbytes, BLCKSZ)));
}
}
This is the only place reporting errors like 'could not read block in file'.
Then I lookead at /src/backend/storage/file/fd.c:
int
FileRead(File file, char *buffer, int amount)
{
..
retry:
returnCode = read(VfdCache[file].fd, buffer, amount);
if (returnCode >= 0)
VfdCache[file].seekPos += returnCode;
else
{
/*
* Windows may run out of kernel buffers and return "Insufficient
* system resources" error. Wait a bit and retry to solve it.
*
* It is rumored that EINTR is also possible on some Unix filesystems,
* in which case immediate retry is indicated.
*/
#ifdef WIN32
...
#endif
/* OK to retry if interrupted */
if (errno == EINTR)
goto retry;
/* Trouble, so assume we don't know the file position anymore */
VfdCache[file].seekPos = FileUnknownPos;
}
return returnCode;
}
First, comment started with 'It is rumored' looks suspiciosly =) But I am not a kernel developer, I am event not a C++ developer, so I trust authors.
I've read 'man read' and 'man 7 signal', and it is said that syscalls could be interrupted by some signals, including sigbus, but when they do so, they should return to normal behaviour.
"the call will be automatically restarted after the signal handler returns if the SA_RESTART flag was used; otherwise the call will fail with the error EINTR" - from man 7 signal
So as I far as I understand even if postgresql gets signal 7 it should experience EINTR and retry immediately. What I am trying to say is that I do not know why I am getting sigbus, but no matter where it comes from, according to sources postgresql should just try to read one more time, and one more, and so on until read succeeded. But I'm not quite sure what happens first - sigbus or 'could not read block' error.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: zlobnynigga@yandex.ru, mmoncure@gmail.com, kevin.grittner@wicourts.gov
Subject: Re: could not read block XXXXX in file "base/YYYYY/ZZZZZZ": read only 160 of 8192 bytes
In-Reply-To: <56961308340142@web152.yandex.ru>
References: <1208551308255001@web137.yandex.ru> <4DFA2130020000250003E76A@gw.wicourts.gov> <438511308318660@web144.yandex.ru> <4DFB32F4020000250003E7E2@gw.wicourts.gov> <BANLkTin8otck1rxoGcBE1wi8PZ1dEt-9fA@mail.gmail.com> <1202541308329125@web105.yandex.ru> <BANLkTim0hL_VkkU7=ozYzRP5+Ruw-BcDuQ@mail.gmail.com> <56961308340142@web152.yandex.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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