Skip site navigation (1) Skip section navigation (2)

Re: Short writes

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Short writes
Date: 2006-11-28 16:05:02
Message-ID: 20061128160502.GD29938@svana.org (view raw or flat)
Thread:
Lists: 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(at)svana(dot)org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

pgsql-hackers by date

Next:From: Andrew SullivanDate: 2006-11-28 16:34:32
Subject: Re: Incrementing INET fields
Previous:From: Tom LaneDate: 2006-11-28 16:02:42
Subject: Re: Short writes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group