Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 32152B5DBCB for ; Fri, 17 Jun 2011 16:49:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 31467-04 for ; Fri, 17 Jun 2011 19:49:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from forward12.mail.yandex.net (forward12.mail.yandex.net [95.108.130.94]) by mail.postgresql.org (Postfix) with ESMTP id 209DFB5D944 for ; Fri, 17 Jun 2011 16:49:04 -0300 (ADT) Received: from web152.yandex.ru (web152.yandex.ru [95.108.131.165]) by forward12.mail.yandex.net (Yandex) with ESMTP id 6D6CEC2228D; Fri, 17 Jun 2011 23:49:03 +0400 (MSD) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1308340143; bh=qriJF+CxTd3LwTbArweeIhntCwUpg5aKbNxkoaPes+M=; h=From:To:Cc:In-Reply-To:References:Subject:MIME-Version:Message-Id: Date:Content-Transfer-Encoding:Content-Type; b=goO2CNEYCNn7jzmGg/CIHjei35KwmBvExIJhNqqEVRPIfBFr5f6/8abl+UvvVGCj1 LaP9FhMnT+UMs3IYJNJXBInWiv/m5id5TZuwikBAaLnUTmWzlbOHx4IuJX0ZPh2IRL XM/KHtKbRcNenPMKveXJ3hLgVPJ3Jr/fSOLkxync= Received: from localhost (localhost.localdomain [127.0.0.1]) by web152.yandex.ru (Yandex) with ESMTP id 4F63067A02CF; Fri, 17 Jun 2011 23:49:03 +0400 (MSD) X-Yandex-Spam: 1 Received: from dhcp174-219-red.yandex.net (dhcp174-219-red.yandex.net [95.108.174.219]) by web152.yandex.ru with HTTP; Fri, 17 Jun 2011 23:49:01 +0400 From: =?koi8-r?B?4c7Uz84g89TF0MHOxc7Lzw==?= To: Merlin Moncure Cc: Kevin Grittner ,pgsql-bugs@postgresql.org In-Reply-To: References: <1208551308255001@web137.yandex.ru> <4DFA2130020000250003E76A@gw.wicourts.gov> <438511308318660@web144.yandex.ru> <4DFB32F4020000250003E7E2@gw.wicourts.gov> <1202541308329125@web105.yandex.ru> Subject: Re: could not read block XXXXX in file "base/YYYYY/ZZZZZZ": read only 160 of 8192 bytes MIME-Version: 1.0 Message-Id: <56961308340142@web152.yandex.ru> Date: Fri, 17 Jun 2011 23:49:01 +0400 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.372 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, FSL_RU_URL=2.271 X-Spam-Level: X-Archive-Number: 201106/156 X-Sequence-Number: 30535 17.06.2011, 21:24, "Merlin Moncure" : > 2011/6/17 áÎÔÏÎ óÔÅÐÁÎÅÎËÏ ;: > >> š17.06.2011, 20:19, "Merlin Moncure" ;: >>> šOn Fri, Jun 17, 2011 at 10:56 AM, Kevin Grittner >>> š;; 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-shared-mmap-access-causes-sigbus-help-203302832.html) > 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.