swift/swift
Alistair Coles 4bb78de611 Fix os.link exceptions in diskfile.relink_paths
Previously, when a diskfile was relinked in a new partition, the
diskfile.relink_paths() would test for the existence of the link
before attempting to create it. This 'test then set' might race with
another process creating the same diskfile (e.g. a concurrent PUT
which created the very same object in an old partition that the
relinker is also relinking). The race might lead to an attempt to
create a link that already exists (despite the pre-check) and an
EEXIST exception being raised.

This patch modifies relink_paths to tolerate EEXIST exceptions but
only if the existing file is a link to the target file. Otherwise the
EEXIST exception is still raised.

The 'check_existing' argument for relink_paths is removed since it is
no longer relevant.

relink_paths() might also raise an ENOENT exception if, while a
diskfile is being relinked in the 'new' partition dir, another process
PUTs a newer version of the same object and as a result cleans up the
older diskfile in the 'old' partition before the first process has
called os.link().

This patch modifies relink_paths() to tolerate ENOENT exceptions from
os.link() but only if the target path (i.e. the file in the 'old'
partition) no longer exists. Otherwise the ENOENT will still be
raised.

This patch also modifies relink_paths() to return a boolean indicating
if the hard link was created by the call to the method (True) or not
(False).

Closes-Bug: 1917658
Change-Id: I65d4b83c56699ed566fbfb7068f9d2681ca67aa3
2021-03-12 09:24:49 -06:00
..
account replace md5 with swift utils version 2020-12-15 09:52:55 -05:00
cli Fix os.link exceptions in diskfile.relink_paths 2021-03-12 09:24:49 -06:00
common Merge "Add unit test for diskfile.relink_paths" 2021-03-09 01:14:14 +00:00
container Merge "sharder: downgrade 'no data dirs' warning to info" 2021-03-02 02:29:16 +00:00
locale Imported Translations from Zanata 2020-10-11 08:24:38 +00:00
obj Fix os.link exceptions in diskfile.relink_paths 2021-03-12 09:24:49 -06:00
proxy Fix logging in proxy container GET path 2021-01-22 13:10:16 +00:00
__init__.py py2: Suppress more CryptographyDeprecationWarnings 2020-11-13 22:04:03 -08:00