[Aptitude-devel] Bug#906695: Bug#906695: aptitude: apt doesn't call fsync on the file extended_states
Mikulas Patocka
mikulas at twibright.com
Wed Aug 22 12:40:39 BST 2018
On Sun, 19 Aug 2018, Mikulas Patocka wrote:
>
>
> On Sun, 19 Aug 2018, Axel Beckert wrote:
>
>> Control: tag -1 + moreinfo
>>
>> ,Hi Mikulas
>>
>> Mikulas Patocka wrote:
>>> Package: aptitude
>> ^^^^^^^^
>>> * What led up to the situation?
>>>
>>> apt doesn't call fsync when writing the file extended_states - so that if
>> ^^^
>>> If you strace aptitude, you can see that it writes the file
>> ^^^^^^^^
>>> I had my file extended_states corrupted when the system crashed while
>>> doing unattended upgrades.
>> ^^^^^^^^^^^^^^^^^^^
>>> apt should call fsync before closing the file handle
>> ^^^
>>
>> You've mentioned three different package managing tools: apt, aptitude
>> and unattended-upgrades.
>>
>> Since you've straced aptitude, I assume you meant aptitude where you
>> wrote apt. But then again unattended-upgrades uses apt, not aptitude.
>>
>> Please clarify!
>>
>> Regards, Axel
>
> All of the apt tools should use fsync (because the machine may crash when the
> user is using any of them).
>
> In my case, unattended-upgrades corrupted the file extended_states when the
> machine crashed, but unattended-upgrades will not write the file if there are
> no upgrades being done, so stracing it doesn't show the bug.
>
> Mikulas
I've straced unattended-upgrade while doing an upgrade and it also doesn't use
fsync, just like aptitude:
1858 openat(AT_FDCWD, "/var/lib/apt/extended_states.lzL2ec", O_RDWR|O_CREAT|O_EXCL, 0600) = 6
1858 umask(000) = 022
1858 umask(022) = 000
1858 fchmod(6, 0644) = 0
1858 fcntl(6, F_SETFD, FD_CLOEXEC) = 0
1858 write(6, "Package: qemu-system-mips\n", 26) = 26
1858 write(6, "Status: install ok installed\n", 29) = 29
1858 write(6, "Priority: optional\n", 19) = 19
1858 write(6, "Section: otherosfs\n", 19) = 19
1858 write(6, "Installed-Size: 38108\n", 22) = 22
1858 write(6, "Maintainer: Debian QEMU Team <pkg-qemu-devel at lists.alioth.debian.org>\n", 70) = 70
1858 write(6, "Architecture: arm64\n", 20) = 20
1858 write(6, "Multi-Arch: foreign\n", 20) = 20
....
1858 write(6, "Package: base-files\n", 20) = 20
1858 write(6, "Architecture: arm64\n", 20) = 20
1858 write(6, "Auto-Installed: 1\n", 18) = 18
1858 write(6, "\n", 1) = 1
1858 write(6, "Package: libvirt-daemon\n", 24) = 24
1858 write(6, "Architecture: arm64\n", 20) = 20
1858 write(6, "Auto-Installed: 1\n", 18) = 18
1858 write(6, "\n", 1) = 1
1858 close(6) = 0
1858 renameat(AT_FDCWD, "/var/lib/apt/extended_states.lzL2ec", AT_FDCWD, "/var/lib/apt/extended_states") = 0
1858 fchmodat(AT_FDCWD, "/var/lib/apt/extended_states", 0644) = 0
1858 close(5) = 0
Mikulas
More information about the Aptitude-devel
mailing list