[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
Just saw this on some field units that are iOT type devices and sometimes get shutdown non-cleanly. We run apt-update on startup and we noticed one machine would not update and had no knowledge of any packages in one of the repos in the sources.list. We noticed the Packages file has 0 size, and no amount of apt update or apt-cache clean could fix it besides deleting/removing the corrupt file. Deleting it resolved the issue: ``` $ ls -lat /var/lib/apt/lists/ total 71252 drwx-- 2 _apt root 4096 Apr 23 16:18 partial drwxr-xr-x 5 root root 4096 Apr 23 15:40 .. drwxr-xr-x 4 root root 4096 Apr 22 21:13 . -rw-r--r-- 1 root root 4342 Apr 22 20:12 [redacted-package-server]-experimental_dists_focal_InRelease -rw-r--r-- 1 root root0 Apr 22 20:12 [redacted-package-server]-experimental_dists_focal_main_binary-amd64_Packages -rw-r--r-- 1 root root 4362 Jan 27 2023 [redacted-package-server]-ubuntu-experimental_dists_focal_InRelease ``` Note the 0 file size on the `[redacted-package- server]-experimental_dists_focal_main_binary-amd64_Packages` file. During this time, it would not Get any new information from the package server. Even with updates pushed to the package server. After removing the file, it does a `Get` and now can see all the packages again: $ sudo mv /var/lib/apt/lists/[redacted-package-server]-experimental_dists_focal_main_binary-amd64_Packages $ sudo apt update Hit:1 [redacted-server]-experimental focal InRelease Hit:2 [redacted-server]-ubuntu-experimental focal InRelease Get:3 [redacted-server]-experimental focal/main amd64 Packages [3524 kB] Fetched 3524 kB in 6s (571 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 27 packages can be upgraded. Run 'apt list --upgradable' to see them. ``` Server software is aptly. apt version is `apt 2.0.6 (amd64)` Happy to track this down and submit a patch for checking the file size of 0, or the algorithm as suggested above. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
** Tags added: fr-281 -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
** Tags added: id-5c336e5b216dc852b7a80d86 -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
"reporting bugs to the effect that a no-change update should finish instantly." By definition, if the on-disk copy is corrupt, there is an change-update available. The algorithm for update should look like this: - does the local copy exist? No -> update available - is the local copy valid (checksums match)? No -> update available - does the remote repo report a change? Yes -> update available "That said, files of size 0 could be made always invalid" My case happened to be corruption of the form of an empty file. Checking the checksum will detect all forms of corruption. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
Note that the file we have in lists/ is not what we downloaded as we have downloaded a highly compressed version of the content (e.g. xz), but store it either uncompressed (for which we have a checksum) or lightly compressed (e.g. lz4 for which we have no checksum and can not as different versions of a compressor could produce different files). So such a check is not exactly free as we need to potentially uncompress the content we want to check – we can't even do a size check in the general case "for free". It might be worth it paying the price in "update", but there are a bunch of people who believe we shouldn't, reporting bugs to the effect that a no-change update should finish instantly. That said, files of size 0 could be made always invalid: We don't download such files nowadays (as an empty file compressed has a [small] size), so files in lists/ should have at least some content and if they don't something is absolutely fishy. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
I agree. ** Changed in: apt (Ubuntu) Status: New => Triaged -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
I was picturing scenario (1); if there are updates or the checksum on the existing doesn't match, download the index. apt has trained users to "apt update" before doing anything else, so this would be okay. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
So, 0.166s is very expensive in the sense that we can't do it every time we open the cache. We're literally optimizing every 10ms we can get there - apt-cache show would be twice as fast. There are two more points where we could do those checks, though: (1) in update - we can check if the lists we have are correct before deciding whether to download new ones (2) in install - we can abort with an error before installing packages The first one should essentially be free, and is probably the best way to fix the issue, as you don't see any upgrades, run update, and see them. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
The problem with deferring the situation to the clean command is that the system appears to be working properly with no problem, and the user will have to _guess_ that cleanup is required. Running md5sum on the packages is not expensive: ubuntu@T00-tx2b:/var/lib/apt/lists$ time md5sum ports.ubuntu.com_ubuntu-ports_dists_xenial_universe_binary-arm64_Packages 005695bf761c4719325927b5a236a77e ports.ubuntu.com_ubuntu-ports_dists_xenial_universe_binary-arm64_Packages real0m0.166s user0m0.136s sys 0m0.036s Certainly it's much faster than the downloading of the indexes in the first place. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
Filesystem is ext4 ubuntu@T00-tx2b:~$ mount /dev/mmcblk0p1 on / type ext4 (rw,relatime,data=ordered) -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
I'm just curious, but what filesystem are those filesystems on? My understanding is that 0 byte files should not happen on ext4 at least. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
[Bug 1809174] Re: apt doesn't detect file corruption in /var/lib/apt/lists
Verifying the checksums in normal operation is too expensive. I think it would be reasonable to make the clean command do that, and remove broken files. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1809174 Title: apt doesn't detect file corruption in /var/lib/apt/lists To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1809174/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs