diskfile: Stop raising ENOENT when we race to mark durable
Change-Id: Ia952303a16457a5075e9a4e060806855c21577f5
This commit is contained in:
parent
660e8386dd
commit
c9b0795b9e
@ -3153,8 +3153,8 @@ class ECDiskFileWriter(BaseDiskFileWriter):
|
||||
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):
|
||||
elif any(frag['timestamp'] >= timestamp
|
||||
for frag in durables):
|
||||
return
|
||||
|
||||
if err.errno not in (errno.ENOSPC, errno.EDQUOT):
|
||||
|
@ -4226,6 +4226,53 @@ class DiskFileMixin(BaseDiskFileTestMixin):
|
||||
with df.open(), open(df._data_file, 'rb') as fp:
|
||||
self.assertEqual(b'dataB', fp.read())
|
||||
|
||||
def test_disk_file_concurrent_marked_durable(self):
|
||||
ts = self.ts()
|
||||
|
||||
def threadA(df, events, errors):
|
||||
try:
|
||||
with df.create() as writer:
|
||||
writer.write(b'dataA')
|
||||
writer.put({
|
||||
'X-Timestamp': ts.internal,
|
||||
'Content-Length': 5,
|
||||
})
|
||||
events[0].set()
|
||||
events[1].wait()
|
||||
writer.commit(ts)
|
||||
except Exception as e:
|
||||
errors.append(e)
|
||||
raise
|
||||
|
||||
def threadB(df, events, errors):
|
||||
try:
|
||||
events[0].wait()
|
||||
# Mark it durable just like in ssync_receiver
|
||||
with df.create() as writer:
|
||||
writer.commit(ts)
|
||||
events[1].set()
|
||||
except Exception as e:
|
||||
errors.append(e)
|
||||
raise
|
||||
|
||||
df = self._simple_get_diskfile()
|
||||
events = [threading.Event(), threading.Event()]
|
||||
errors = []
|
||||
|
||||
threads = [threading.Thread(target=tgt, args=(df, events, errors))
|
||||
for tgt in (threadA, threadB)]
|
||||
for thread in threads:
|
||||
thread.start()
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
self.assertFalse(errors)
|
||||
|
||||
with df.open(), open(df._data_file, 'rb') as fp:
|
||||
if df.policy.policy_type == EC_POLICY:
|
||||
# Confirm that it really *was* marked durable
|
||||
self.assertTrue(df._data_file.endswith('#d.data'))
|
||||
self.assertEqual(b'dataA', fp.read())
|
||||
|
||||
def test_disk_file_concurrent_delete(self):
|
||||
def threadA(df, events, errors):
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user