Re: Short writes - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Short writes
Date
Msg-id 20061128160502.GD29938@svana.org
Whole thread Raw
In response to Short writes  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Short writes
Re: Short writes
List pgsql-hackers
On Tue, Nov 28, 2006 at 04:51:35PM +0100, Peter Eisentraut wrote:
> We are currently debugging a problem with error messages like this:
>
> ERROR:  53100: could not write block 2427137 of relation
> 1663/706306048/706314280: No space left on device
>
> The device has plenty of space left.  The problem appears to be this
> curious code in src/backend/storage/file/fd.c:
>
>     /* if write didn't set errno, assume problem is no disk space */
>     if (returnCode != amount && errno == 0)
>         errno = ENOSPC;
>
> What is the rationale for making this assumption?

Essentially, for files short writes are not supposed to happen. For
pipes and sockets it's fairly normal, but for files it's not expected
to ever happen.

Given that write() only has one return value, if all the data cannot be
written, it has to return the number of bytes written and can't return
the actual error.

What probably *should* happen is that a second write is initiated to
write the remainder of the block, at which point the system can say
"disk full".

> We haven't yet figured out why the above error happens, but I suggest
> that we at least make a more accurate error message.

It would be interesting to know what other causes there could be for
short writes.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: BLCKSZ fun facts
Next
From: Bruce Momjian
Date:
Subject: Re: FAQs and Port Status