Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 783147 - sys-apps/portage: emerge sync verification with gemato raised unhandled OSError: [Errno 5] Input/output error
Summary: sys-apps/portage: emerge sync verification with gemato raised unhandled OSErr...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-16 12:39 UTC by Zoltan Puskas
Modified: 2021-04-18 20:49 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltan Puskas 2021-04-16 12:39:25 UTC
# emerge --sync
---8<---
sent 105.17K bytes  received 22.46M bytes  1.46M bytes/sec
total size is 217.44M  speedup is 9.64
 * Manifest timestamp: 2021-04-16 12:08:36 UTC
 * Valid OpenPGP signature found:
 * - primary key: DCD05B71EAB94199527F44ACDB6B8C1F96D8BF6D
 * - subkey: E1D6ABB63BFCFB4BA02FDF1CEC590EEAC9189250
 * - timestamp: 2021-04-16 12:08:36 UTC
 * Verifying /var/db/repos/gentoo/.tmp-unverified-download-quarantine ...Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/portage/util/_async/AsyncFunction.py", line 39, in _run
    result = self.target(*(self.args or []), **(self.kwargs or {}))
  File "/usr/lib/python3.8/site-packages/portage/sync/controller.py", line 165, in sync
    taskmaster.run_tasks(tasks, func, status, options=task_opts)
  File "/usr/lib/python3.8/site-packages/portage/sync/controller.py", line 65, in run_tasks
    result = getattr(inst, func)(**kwargs)
  File "/usr/lib/python3.8/site-packages/portage/sync/syncbase.py", line 338, in sync
    return self.update()
  File "/usr/lib/python3.8/site-packages/portage/sync/modules/rsync/rsync.py", line 401, in update
    m.assert_directory_verifies()
  File "/usr/lib/python3.8/site-packages/gemato/recursiveloader.py", line 628, in assert_directory_verifies
    entry_dict = self.get_file_entry_dict(path)
  File "/usr/lib/python3.8/site-packages/gemato/recursiveloader.py", line 557, in get_file_entry_dict
    self.load_manifests_for_path(path, recursive=True,
  File "/usr/lib/python3.8/site-packages/gemato/recursiveloader.py", line 446, in load_manifests_for_path
    self.loaded_manifests.update(manifests)
  File "/usr/lib/python3.8/site-packages/gemato/recursiveloader.py", line 99, in __call__
    return (args[0], self.verify_and_load(*args)[0])
  File "/usr/lib/python3.8/site-packages/gemato/recursiveloader.py", line 78, in verify_and_load
    ret, diff = verify_path(path, verify_entry)
  File "/usr/lib/python3.8/site-packages/gemato/verify.py", line 200, in verify_path
    checksums = next(g)
  File "/usr/lib/python3.8/site-packages/gemato/verify.py", line 118, in get_file_metadata
    checksums = hash_file(f, hashes, _apparent_size=st.st_size)
  File "/usr/lib/python3.8/site-packages/gemato/hash.py", line 64, in hash_file
    block = f.read()
OSError: [Errno 5] Input/output error


Reproducible: Always




# emerge --info
Portage 3.0.18 (python 3.8.9-final-0, default/linux/amd64/17.1/no-multilib/hardened, gcc-9.3.0, glibc-2.33, 5.11.13-gentoo x86_64)
=================================================================
System uname: Linux-5.11.13-gentoo-x86_64-Intel-R-_Celeron-R-_CPU_N3450_@_1.10GHz-with-glibc2.2.5
KiB Mem:     8006844 total,   2451772 free
KiB Swap:    2097148 total,   2097148 free
Timestamp of repository gentoo: Thu, 15 Apr 2021 00:45:01 +0000
Head commit of repository gentoo: e1abdfa26b703d721420701e1ec6f38b13938168
sh bash 5.1_p4
ld GNU ld (Gentoo 2.35.2 p1) 2.35.2
app-shells/bash:          5.1_p4::gentoo
dev-lang/perl:            5.32.1::gentoo
dev-lang/python:          3.8.9::gentoo, 3.9.4::gentoo
dev-lang/rust:            1.51.0::gentoo
dev-util/cmake:           3.20.1::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.7-r1::gentoo
sys-apps/openrc:          0.42.1-r1::gentoo
sys-apps/sandbox:         2.23::gentoo
sys-devel/autoconf:       2.69-r5::gentoo
sys-devel/automake:       1.16.3-r1::gentoo
sys-devel/binutils:       2.35.2::gentoo
sys-devel/gcc:            9.3.0-r2::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.11::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts:

sinustrom
    location: /var/lib/layman/sinustrom
    sync-type: laymansync
    sync-uri: https://github.com/zpuskas/sinustrom-gentoo-overlay.git
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=native -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe"
GENTOO_MIRRORS="http://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/"
LANG="en_US.utf8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j4"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="7zip acl acpi aes amd64 bash-completion bzip2 crypt gmp hardened iconv ipv6 libglvnd libtirpc lzma mmx mmxext ncurses networkmanager nls nptl opencl opengl openmp pam pcre pie popcnt posix readline seccomp smp sockets split-usr sse sse2 sse3 sse4_1 sse4_2 ssl ssp ssse3 threads uicode unicode usb vim-syntax xattr xtpax zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_8" PYTHON_TARGETS="python3_8" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS
Comment 1 Zac Medico gentoo-dev 2021-04-17 02:11:15 UTC
An EIO error is generally unexpected here. It is a form of verification error, and we really should log the full traceback due to the unexpected nature of the error.
Comment 2 Zac Medico gentoo-dev 2021-04-17 17:55:21 UTC
Do you know the root cause of your EIO error? It could have been due to a hardware or file system problem. If it's not reproducible, and you've determined that the underlying file system and media are healthy, then there's nothing to do except possibly consider how you can prevent this from occurring again (some form of RAID with error correction could possibly help).
Comment 3 Zoltan Puskas 2021-04-18 20:49:31 UTC
(In reply to Zac Medico from comment #2)
> Do you know the root cause of your EIO error? It could have been due to a
> hardware or file system problem. If it's not reproducible, and you've
> determined that the underlying file system and media are healthy, then
> there's nothing to do except possibly consider how you can prevent this from
> occurring again (some form of RAID with error correction could possibly
> help).

# TL;DR

- A single file was corrupted (either file or the checksum) and BTRFS did it's thing, thus it became an I/O error.
- Removing the file and running `emerge --sync` again resolved the issue.
- It would be nice if verification code could print out which files have failed the verification.

# Root causing

I had some time over the weekend to look into this on my side. My portage tree is located in /var/db/repos/gentoo, which is the / partition of the SSD. Host seems to work properly otherwise, mount is RW. In the end I managed find the issue that causes this failure, not sure about the root cause for that failure though.

What I did:
- Ran `emerge-webrsync`. I was thinking maybe there is a portage tree corruption and this will fix it. It did not.
- Ran `btrfs check`, which returned no errors.
- Ran `smartctl -t short /dev/sda3`, which returned no error. My SSD's TBW and age numbers are also well within their useful life.
- Ran `btrfs scrub start /dev/sda3`, which found 2 uncorrectable errors: 

$ dmesg | grep "checksum error at" | cut -d\  -f24- | sed 's/.$//'
4096, links 1 (path: var/db/repos/gentoo/app-arch/dpkg/Manifest
2341, links 1 (path: var/db/repos/gentoo/app-arch/dpkg/Manifest

Running

$ less /var/db/repos/gentoo/app-arch/dpkg/Manifest

gave me a read error. I'm not sure how this file got corrupted. Maybe it happened due to a power outage or a cosmic ray or something else.

Removing the file and rerunning portage tree sync fixed things. So in the end portage was correct to fail the verification, but it was more cryptic then it should be. Rather then a full stack trace maybe bubbling up an exception and catching it to print a proper error message would be more useful.