obj: _finalize_durable may succeed even when data file is missing (LOSF)

Bring 69b8165cd8 to LOSF

Change-Id: I91c72a7a98468497ab323a920e9573fcec765b66
This commit is contained in:
Alexandre Lécuyer 2020-05-25 15:36:15 +02:00
parent 414ca6bb6c
commit b3fd0bd9d8
2 changed files with 26 additions and 2 deletions

View File

@ -1137,13 +1137,29 @@ class ECKVFileReader(BaseKVFileReader, ECDiskFileReader):
class ECKVFileWriter(BaseKVFileWriter, ECDiskFileWriter):
# TODO: this needs to be updated wrt. next_part_power, and other changes
# in diskfile.py
def _finalize_durable(self, data_file_path, durable_data_file_path):
def _finalize_durable(self, data_file_path, durable_data_file_path,
timestamp):
exc = None
try:
try:
vfile.rename_vfile(data_file_path, durable_data_file_path,
self._diskfile._logger)
except (OSError, IOError) as err:
if err.errno == errno.ENOENT:
files = vfile.listdir(self._datadir)
results = self.manager.get_ondisk_files(
files, self._datadir,
frag_index=self._diskfile._frag_index,
policy=self._diskfile.policy)
# We "succeeded" if another writer cleaned up our data
ts_info = results.get('ts_info')
durables = results.get('durable_frag_set', [])
if ts_info and ts_info['timestamp'] > timestamp:
return
elif any(frag_set['timestamp'] > timestamp
for frag_set in durables):
return
if err.errno not in (errno.ENOSPC, errno.EDQUOT):
# re-raise to catch all handler
raise

View File

@ -1190,4 +1190,12 @@ def rename_vfile(filepath, newfilepath, logger):
os.close(vol_fd)
# Update the KV (async)
rpc.rename_object(si.socket_path, full_name, new_full_name)
try:
rpc.rename_object(si.socket_path, full_name, new_full_name,
si.partition)
except RpcError as e:
if e.code == StatusCode.NotFound:
raise VIOError(errno.ENOENT,
"No such file or directory: {}".format(full_name))
else:
raise