Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 666554 - sys-apps/portage-2.3.49: emerge --sync destroys portage tree if "sync-allow-hardlinks = yes" (on fs with hardlink support)
Summary: sys-apps/portage-2.3.49: emerge --sync destroys portage tree if "sync-allow-h...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: AMD64 Linux
: Normal major (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 666956
  Show dependency tree
 
Reported: 2018-09-19 12:11 UTC by Erik Quaeghebeur
Modified: 2019-04-20 18:25 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 Erik Quaeghebeur 2018-09-19 12:11:59 UTC
After the upgrade to portage-2.3.49 almost two days ago, a subsequent emerge --sync failed with

    rsync warning: some files vanished before they could be transferred (code 24) at main.c(1189) [sender=3.1.3]

and

    Action: sync for repo: gentoo, returned code = 24

My portage tree (/usr/portage) was effectively destroyed. Namely, all but a few category directories (app-a…) were empty and I had a big directory .tmp-unverified-download-quarantine.

emerge-webrsync fixed things and also setting "sync-allow-hardlinks = no", even if my tree is just a directory on a normal ext4 partition (root partition actually), as per fstab:

    LABEL=ROOT    /    ext4    lazytime,discard,user_xattr    0 1

So I guess that the feature introduced with Bug #660410 breaks in a bad way in more cases than just when no hardlinks are possible (I verified that I can create hardlinks on that partition).

This issue is being discussed in the forum thread https://forums.gentoo.org/viewtopic-p-8262472.html.

Let me know what further information you need to identify the cause, if any.

Reproducible: Always

Steps to Reproduce:
1. Have "sync-allow-hardlinks = yes" in repos.conf (the default)
2. emerge --sync
portage tree destroyed



# emerge --info                                                                                                                                                    
Portage 2.3.49 (python 3.6.5-final-0, default/linux/amd64/17.0/desktop/plasma/systemd, gcc-7.3.0, glibc-2.26-r7, 4.14.65-gentoo x86_64)                                                             
=================================================================                                                                                                                                   
System uname: Linux-4.14.65-gentoo-x86_64-Intel-R-_Core-TM-_i7-2620M_CPU_@_2.70GHz-with-gentoo-2.4.1                                                                                                
KiB Mem:     8044284 total,   2186224 free                                                                                                                                                          
KiB Swap:    8388692 total,   7557136 free                                                                                                                                                          
Timestamp of repository gentoo: Wed, 19 Sep 2018 09:30:01 +0000                                                                                                                                     
Head commit of repository gentoo: 304f92c5822a92d25062f2edb1b5db9c1b1a1979                                                                                                                          
sh bash 4.4_p12                                                                                                                                                                                     
ld GNU ld (Gentoo 2.30 p2) 2.30.0                                                                                                                                                                   
app-shells/bash:          4.4_p12::gentoo                                                                                                                                                           
dev-java/java-config:     2.2.0-r4::gentoo                                                                                                                                                          
dev-lang/perl:            5.24.3-r1::gentoo                                                                                                                                                         
dev-lang/python:          2.7.15::gentoo, 3.6.5::gentoo                                                                                                                                             
dev-util/cmake:           3.9.6::gentoo                                                                                                                                                             
sys-apps/baselayout:      2.4.1-r2::gentoo                                                                                                                                                          
sys-apps/sandbox:         2.13::gentoo                                                                                                                                                              
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo                                                                                                                                             
sys-devel/automake:       1.11.6-r3::gentoo, 1.15.1-r2::gentoo                                                                                                                                      
sys-devel/binutils:       2.30-r2::gentoo                                                                                                                                                           
sys-devel/gcc:            7.3.0-r3::gentoo                                                                                                                                                          
sys-devel/gcc-config:     1.8-r1::gentoo                                                                                                                                                            
sys-devel/libtool:        2.4.6-r3::gentoo                                                                                                                                                          
sys-devel/make:           4.2.1-r4::gentoo                                                                                                                                                          
sys-kernel/linux-headers: 4.13::gentoo (virtual/os-headers)                                                                                                                                         
sys-libs/glibc:           2.26-r7::gentoo                                                                                                                                                           
Repositories:                                                                                                                                                                                       
                                                                                                                                                                                                    
gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: --exclude ChangeLog --delete-excluded

ownDevel
    location: /usr/local/portage
    masters: gentoo

raiagent
    location: /var/lib/layman/raiagent
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d
 /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--misspell-suggestions=n --with-bdeps=y"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY 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="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms split-e
log split-log strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://mirror.leaseweb.com/gentoo/ ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo ftp://ftp.halifax.rwth-aachen.de/gentoo/ ftp://ftp.free.fr/mirrors/ftp.gentoo.org/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="nl en_US en"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--exclude ChangeLog --delete-excluded"
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="X a52 aac acl acpi activities alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cli crypt cups cxx dbus declarative dri dts dvd dvdr egl emboss encode exif fam fftw flac fortran gdbm
gif glamor gmp gpm iconv icu ipv6 jpeg kde kipi kwallet lcms ldap libnotify libtirpc mad mmap mng modules mp3 mp4 mpeg multilib ncurses networkmanager nls nptl ogg opengl openmp pam pango pch pcre
 pdf phonon plasma png policykit ppds pulseaudio qml qt5 readline resolvconf sdl seccomp semantic-desktop spell ssl startup-notification svg system-harfbuzz system-icu system-jpeg system-libevent
system-libvpx system-sqlite systemd tcpd tiff truetype udev udisks unicode upower usb vaapi vorbis widgets wifi x264 xattr xcb xcomposite xml xv xvid zeroconf zlib" ABI_X86="64" ALSA_CARDS="ali545
1 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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 rewrit
e setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon plan sheets stage words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_
X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navco
m oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev synaptics" KERNEL="linux" L10N="nl en-US en" LCD_DEVICES="bayrad
cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POST$
RES_TARGETS="postgres9_5 postgres10" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" RUBY_TARGETS="ruby23" USERLAND="GNU" VIDEO_CARDS="fbdev intel modesetting vesa" XTABLES_$
DDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS
Comment 1 Zac Medico gentoo-dev 2018-09-19 16:39:46 UTC
(In reply to Erik Quaeghebeur from comment #0)
> PORTAGE_RSYNC_EXTRA_OPTS="--exclude ChangeLog --delete-excluded"

It's probably the --delete-excluded option that triggers the issue, since --exclude is used to temporarily protect the .tmp-unverified-download-quarantine directory.
Comment 2 Gary E. Miller 2018-09-19 17:23:12 UTC
Same issue here.

Removing --delete-excluded from PORTAGE_RSYNC_EXTRA_OPTS resolved it.
Comment 3 Don O 2018-09-19 20:47:15 UTC
In my case, from this morning

>>> Checking server timestamp ...
 * Manifest timestamp: 2018-09-19 06:08:41 UTC
 * Valid OpenPGP signature found:
 * - primary key: DCD05B71EAB94199527F44ACDB6B8C1F96D8BF6D
 * - subkey: E1D6ABB63BFCFB4BA02FDF1CEC590EEAC9189250
 * - timestamp: 2018-09-19 06:08:41 UTC
 * Verifying /usr/portage/.tmp-unverified-download-quarantine ...!!! Manifest verification failed:
Manifest mismatch for metadata/Manifest.gz
  __size__: expected: 1981, have: 1980
q: Updating ebuild cache in /usr/portage ... 
q: Finished 35962 entries in 0.355340 seconds

Action: sync for repo: gentoo, returned code = 1


Which left me with stuff in .tmp-unverified-download-quarantine and me not sure what state my system was in.

So I set sync-allow-hardlinks = no, deleted everything under /usr/portage including the hidden file and resync'd. 

Worked that time. 

I don't have any PORTAGE_RSYNC_EXTRA_OPTS set.
Comment 4 Zac Medico gentoo-dev 2018-09-24 06:18:09 UTC
(In reply to Don O from comment #3)
> In my case, from this morning
> 
> >>> Checking server timestamp ...
>  * Manifest timestamp: 2018-09-19 06:08:41 UTC
>  * Valid OpenPGP signature found:
>  * - primary key: DCD05B71EAB94199527F44ACDB6B8C1F96D8BF6D
>  * - subkey: E1D6ABB63BFCFB4BA02FDF1CEC590EEAC9189250
>  * - timestamp: 2018-09-19 06:08:41 UTC
>  * Verifying /usr/portage/.tmp-unverified-download-quarantine ...!!!
> Manifest verification failed:
> Manifest mismatch for metadata/Manifest.gz
>   __size__: expected: 1981, have: 1980
> q: Updating ebuild cache in /usr/portage ... 
> q: Finished 35962 entries in 0.355340 seconds
> 
> Action: sync for repo: gentoo, returned code = 1
> 
> 
> Which left me with stuff in .tmp-unverified-download-quarantine and me not
> sure what state my system was in.

It's intended to leave the .tmp-unverified-download-quarantine directory for forensic purposes. You're safe, since the files in that directory have not been merged into your main tree.

> So I set sync-allow-hardlinks = no, deleted everything under /usr/portage
> including the hidden file and resync'd. 

Since you did that, new files will not be quarantined, making you vulnerable to potentially malicious files.
Comment 5 Zac Medico gentoo-dev 2018-09-24 06:21:09 UTC
(In reply to Gary E. Miller from comment #2)
> Same issue here.
> 
> Removing --delete-excluded from PORTAGE_RSYNC_EXTRA_OPTS resolved it.

Thanks for confirmation. Since PORTAGE_RSYNC_EXTRA_OPTS does not need to be included in the this particular (local) rsync call, it's fixed by this commit, where PORTAGE_RSYNC_EXTRA_OPTS is no longer used for the relevant local rsync call:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=884ad951d700d1871cab2e321e4d8635b1a0f698

commit 884ad951d700d1871cab2e321e4d8635b1a0f698
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2018-07-30 06:21:30 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2018-09-24 04:24:10 +0000

    rsync: split out repo storage framework
    
    Since there are many ways to manage repository storage, split out a repo
    storage framework. The HardlinkQuarantineRepoStorage class implements
    the existing default behavior, and the InplaceRepoStorage class
    implements the legacy behavior (when sync-allow-hardlinks is disabled in
    repos.conf).
    
    Each class implements RepoStorageInterface, which uses coroutine methods
    since coroutines are well-suited to the I/O bound tasks that these
    methods perform. The _sync_decorator is used to convert coroutine
    methods to synchronous methods, for smooth integration into the
    surrounding synchronous code.
    
    Bug: https://bugs.gentoo.org/662070
    Reviewed-by: Brian Dolbec <dolsen@gentoo.org>
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/repository/storage/__init__.py         |  2 +
 .../repository/storage/hardlink_quarantine.py      | 95 ++++++++++++++++++++++
 lib/portage/repository/storage/inplace.py          | 49 +++++++++++
 lib/portage/repository/storage/interface.py        | 87 ++++++++++++++++++++
 lib/portage/sync/controller.py                     |  1 +
 lib/portage/sync/modules/rsync/rsync.py            | 85 +++++--------------
 lib/portage/sync/syncbase.py                       | 53 +++++++++++-
 7 files changed, 306 insertions(+), 66 deletions(-)
Comment 6 Zac Medico gentoo-dev 2018-09-28 05:18:21 UTC
(In reply to Zac Medico from comment #5)
> (In reply to Gary E. Miller from comment #2)
> > Same issue here.
> > 
> > Removing --delete-excluded from PORTAGE_RSYNC_EXTRA_OPTS resolved it.
> 
> Thanks for confirmation. Since PORTAGE_RSYNC_EXTRA_OPTS does not need to be
> included in the this particular (local) rsync call, it's fixed by this
> commit, where PORTAGE_RSYNC_EXTRA_OPTS is no longer used for the relevant
> local rsync call:
> 
> https://gitweb.gentoo.org/proj/portage.git/commit/
> ?id=884ad951d700d1871cab2e321e4d8635b1a0f698
> 
> commit 884ad951d700d1871cab2e321e4d8635b1a0f698
> Author:     Zac Medico <zmedico@gentoo.org>
> AuthorDate: 2018-07-30 06:21:30 +0000
> Commit:     Zac Medico <zmedico@gentoo.org>
> CommitDate: 2018-09-24 04:24:10 +0000
> 
>     rsync: split out repo storage framework
>     
>     Since there are many ways to manage repository storage, split out a repo
>     storage framework. The HardlinkQuarantineRepoStorage class implements
>     the existing default behavior, and the InplaceRepoStorage class
>     implements the legacy behavior (when sync-allow-hardlinks is disabled in
>     repos.conf).

It needs to be fixed to exclude these directories

  /distfiles
  /local
  /lost+found
  /packages
Comment 7 Larry the Git Cow gentoo-dev 2018-09-28 05:48:08 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=b587fc874ce95064139ba85552e146da957cce9e

commit b587fc874ce95064139ba85552e146da957cce9e
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2018-09-28 05:32:31 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2018-09-28 05:43:26 +0000

    HardlinkQuarantineRepoStorage: exclude distfiles and packages (bug 666554)
    
    These paths have been excluded for a long time, and they are also
    whitelisted in the top-level Manifest.files.gz:
    
        IGNORE distfiles
        IGNORE local
        IGNORE lost+found
        IGNORE packages
    
    Bug: https://bugs.gentoo.org/666554
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/repository/storage/hardlink_quarantine.py | 2 ++
 1 file changed, 2 insertions(+)
Comment 8 Larry the Git Cow gentoo-dev 2018-09-28 05:52:47 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fe57099ad3c1e2002a231f5028675d478751605f

commit fe57099ad3c1e2002a231f5028675d478751605f
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2018-09-28 05:49:44 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2018-09-28 05:52:38 +0000

    sys-apps/portage: 2.3.50-r4 revbump for bug 666554
    
    Bug: https://bugs.gentoo.org/666554
    Signed-off-by: Zac Medico <zmedico@gentoo.org>
    Package-Manager: Portage-2.3.50, Repoman-2.3.10

 .../portage/{portage-2.3.50-r3.ebuild => portage-2.3.50-r4.ebuild}    | 4 ++++
 1 file changed, 4 insertions(+)