[pacman-dev] delay writes a fsync

Dan McGee dpmcgee at gmail.com
Thu Mar 12 11:06:05 EDT 2009


On Thu, Mar 12, 2009 at 5:18 AM, Xavier <shiningxc at gmail.com> wrote:
> On Thu, Mar 12, 2009 at 9:19 AM, Allan McRae <allan at archlinux.org> wrote:
>> Hi,
>>
>> You have probably heard about this:
>> http://linux.slashdot.org/article.pl?sid=09/03/11/2031231
>>
>> Here is the link to the bug report that describes the cause of the problem:
>> https://bugs.edge.launchpad.net/ubuntu/+source/linux/+bug/317781/comments/54
>>
>> A key part of the bug report comment...
>> Applications are expected to use fsync() or fdatasync(), and if that impacts
>> their performance too much, to use a single berkdb or other binary database
>> file, and not do something stupid with hundreds of tiny text files that only
>> hold a few bytes of data in each text file.
>>
>> Hmmm...  something sound familiar there?
>> So what should we do? Maybe, add some sort of syncing after a db write. But
>> then after each file or just at the end of the transaction?
>>
>
> If I remember correctly, the code does this :
> pkg1 : extract files ; write db entry
> pkg2 : extract files ; write db entry
> etc ..
>
> So yeah, it could make sense to sync after each db write to have a
> consistent database after each package install.

Adding an fsync() in the write_db_entry() call would probably make sense.

However, note the funny part here- if we sync our DB entries, and then
your machine gets powered off, you might end up with a DB that got
committed but files in the package never actually got written to disk.

-Dan


More information about the pacman-dev mailing list