From sokol at insa-toulouse.fr  Wed Jul  5 14:46:52 2017
From: sokol at insa-toulouse.fr (Serguei Sokol)
Date: Wed, 5 Jul 2017 14:46:52 +0200
Subject: [Rd] [New Patch] Fix disk corruption when writing
In-Reply-To: <1093380f-a632-ce28-af21-a87e1a40a8db@gmail.com>
References: <CAPXDfF=770SgtaLoMeaF7XGUfj3wFSU6hUn6ZFrds0VnwG_+zA@mail.gmail.com>
 <ba1bb252-8524-ce6d-b0d7-0d66a09789d2@gmail.com>
 <CA+A1kV5xB3yfD2SnKenrnrfgV6wDObQW8vFMxUVQd2kxTc0BjQ@mail.gmail.com>
 <1093380f-a632-ce28-af21-a87e1a40a8db@gmail.com>
Message-ID: <8ede4416-7745-e66c-7d2f-53c04f1a9067@insa-toulouse.fr>

Le 05/07/2017 ? 13:09, Duncan Murdoch a ?crit :
> On 05/07/2017 5:26 AM, January W. wrote:
>> I tried the newest patch, but it does not seem to work for me (on
>> Linux). Despite the check in Rconn_printf, the write.csv happily writes
>> to /dev/full and does not report an error. When I added a printf("%d\n",
>> res); to the Rconn_printf() definition, I see only positive values
>> returned by the vfprintf call.
>>
>
> That's likely because you aren't writing enough to actually trigger a write to disk during the write.  Writes are buffered, and the error doesn't happen until 
> the buffer is written.
I can confirm this behavior with fvprintf(). Small and medium sized writings
on /dev/full don't trigger error and 1MB does.

But if fprintf() is used, it returns a negative value from the very first byte written.

Serguei.

>   The regression test I put in had this problem; I'm working on MacOS and Windows, so I never got to actually try it before committing.
>
> Unfortunately, it doesn't look possible to catch the final flush of the buffer when the connection is closed, so small writes won't trigger any error.
>
> It's also possible that whatever system you're on doesn't signal an error when the write fails.
>
> Duncan Murdoch
>
>> Cheers,
>>
>> j.
>>
>>
>> On 4 July 2017 at 21:37, Duncan Murdoch <murdoch.duncan at gmail.com
>> <mailto:murdoch.duncan at gmail.com>> wrote:
>>
>>     On 04/07/2017 11:50 AM, Jean-S?bastien Bevilacqua wrote:
>>
>>         Hello,
>>         You can find here a patch to fix disk corruption.
>>         When your disk is full, the write function exit without error
>>         but the file
>>         is truncated.
>>
>> https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17243
>> <https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17243>
>>
>>
>>     Thanks.  I didn't see that when it came through (or did and forgot).
>>     I'll probably move the error check to a lower level (in the
>>     Rconn_printf function), if tests show that works.
>>
>>     Duncan Murdoch
>>
>>
>>     ______________________________________________
>>     R-devel at r-project.org <mailto:R-devel at r-project.org> mailing list
>>     https://stat.ethz.ch/mailman/listinfo/r-devel
>>     <https://stat.ethz.ch/mailman/listinfo/r-devel>
>>
>>
>>
>>
>> -- 
>> -------- January Weiner --------------------------------------
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


-- 
Serguei Sokol
Ingenieur de recherche INRA
Metabolisme Integre et Dynamique des Systemes Metaboliques (MetaSys)

LISBP, INSA/INRA UMR 792, INSA/CNRS UMR 5504
135 Avenue de Rangueil
31077 Toulouse Cedex 04

tel: +33 5 6155 9276
fax: +33 5 6704 8825
email: sokol at insa-toulouse.fr
http://metasys.insa-toulouse.fr
http://www.lisbp.fr



[Rd] [New Patch] Fix disk corruption when writing
Serguei Sokol