[Xapian-discuss] "Error reading block xxx: got end of file"

Eric B. Ridge ebr@tcdi.com
Wed, 09 Jun 2004 20:33:45 -0400


On 6/9/04 7:36 PM, "Olly Betts" <olly@survex.com> wrote:

> On Wed, Jun 09, 2004 at 06:44:37PM -0400, Eric B. Ridge wrote:
>> Been digging through our logs more carefully today, discovered this
>> XapianError:
>> 
>> org.xapian.errors.DatabaseError: Error writing block: Bad file descriptor
>>   at org.xapian.XapianJNI.writabledatabase_repalce_document(Native Method)
>>   at org.xapian.WritableDatabase.replaceDocument(WritableDatabase.java:67)
>> 
>> It seems once this occurs, we constantly get the "got end of file" errors
>> until we restart our process.
> 
> This is from the 0.8.0 release version?

Yes it is.  Directly from www.xapian.org, not from CVS.

<snip>

> I don't quite see why you'd get "got end of file" though.  If the
> descriptor is bad (-1 is most likely) the return value should be -1 (and errno
> should be EBADF) but "got end of file" means read returned 0.

That's a good point.  We've been getting different block numbers for each
EOF error.  Sometimes small numbers, sometimes big numbers.  Which makes me
think it's not really the end of the file... .replace_document() just thinks
it is.

Is it possible that the fd is going bad during the system-level read or
write operations?

>
> And besides, if open returns -1, this should cause an exception.  Hmm,
> or perhaps the Java wrappers are somehow causing something unfortunate
> to happen in this situation.

I don't know what the Java wrappers could be doing here.  They re-throw (as
Java exceptions) any C++ exception thrown by Xapian.  I'll double-check the
code in the JNI wrapper for WritableDatabase tho, just to make sure I'm not
ignoring a C++ exception somewhere else.

<short pause>  Did 0.8.0 introduce any new exception types?

> It'd be interesting to see what the fd is.  Try adding it to the exception
> messages - in backends/quartz/btree.cc, add:
> 
>             message += " (fd = " + om_tostring(handle) + ")";
> 
> Add it just before the throw here in write_block():

Okay, I'll do this too.  This error is soooo random -- didn't happen at all
today!.  No idea when we'll actually see the error again.

eric