Opened 11 years ago

Closed 11 years ago

#1201 closed defect (fixed)

rails GPX upload race condition

Reported by: jburgess777@… Owned by: Tom Hughes
Priority: minor Milestone:
Component: api Version:
Keywords: Cc:

Description

While testing the new C based GPX importer I got a stack trace from ruby about a missing file. It looks to me like the trace_controller adds the entry to the DB before the file is moved to the trace directory. There is a chance for the import daemon to try picking up the file in this interval.

Currently:

sites/rails_port/app/controllers/trace_controller.rb

    if @trace.save
      FileUtils.mv(filename, @trace.trace_name)
    else
      FileUtils.rm_f(filename)

Suggest something like...

    FileUtils.mv(filename, @trace.trace_name)
    if not @trace.save
      FileUtils.rm_f(@trace.trace_name)

Change History (3)

comment:1 Changed 11 years ago by jburgess777@…

On IRC Daniel Silverstone pointed out that perhaps the trace.id (and hence the trace_name) may not be valid until the the entry is saved which may cause a problem with the suggestion.

Daniel might add a delay to the import daemon to avoid this when fetching new traces for processing.

comment:2 Changed 11 years ago by dsilvers@…

In r35 of my gpx-import branch (bzr branch http://bzr.digital-scurf.org/trees/dsilvers/gpx-import) I added code to make it so that rows in the DB need to be timestamped at least SLEEP_TIME seconds in the past (default is 30).

That should give the rails app a chance to get the gpx into place.

comment:3 Changed 11 years ago by tomhughes

Resolution: fixed
Status: newclosed

(In [11194]) Fix race condition adding traces. Closes #1201.

Note: See TracTickets for help on using tickets.