race condition when creating new symlinks
There have been a couple of scenarios when RAVEN (@brandon.piotrzkowski) has tried to simultaneously upload multiple files of the same filename (i.e., coincidence_far.json
) at the same time, and while the code made it past the part in the code where it removes the old symlink, it would OSError
(traceback at the end of this issue) when trying to create a new one because another process beat it to it.
This commit: 3daa20fd fixes it by just catching the exception and moving on. The versioned file still gets created in the logs and is still available, but there's no real scenario in which we should implement the logic to prioritize one symlink over the other in this case.
...
...
File "/app/gracedb_project/gracedb/superevents/utils.py", line 248, in create_log
raise e
File "/app/gracedb_project/gracedb/superevents/utils.py", line 244, in create_log
event_or_superevent.datadir, data_file)
File "/app/gracedb_project/gracedb/core/vfile.py", line 271, in create_versioned_file
fdest.close()
File "/app/gracedb_project/gracedb/core/vfile.py", line 224, in close
self._repoint_symlink()
File "/app/gracedb_project/gracedb/core/vfile.py", line 191, in _repoint_symlink
os.symlink(name, self.fullname)
Exception Type: FileExistsError at /api/superevents/MS221004az/logs/
Exception Value: [Errno 17] File exists: 'coincidence_far.json,7' -> '/app/gracedb_project/../db_data/5f/8/0bea0146287984087bb980b9a0d5840958463/coincidence_far.json'
Request information:
USER: emfollow
GET: No GET data
POST:
tagname = 'ext_coinc'
comment = "RAVEN: Computed coincident FAR(s) in Hz with external trigger <a href='https://gracedb-test.ligo.org/events/M315290'>M315290</a>"