]> git.openstreetmap.org Git - rails.git/commit
Don't destroy traces while they are being imported
authorvignesh-chaturvedi <vigneshchaturvedi@gmail.com>
Thu, 22 Oct 2026 23:25:32 +0000 (04:55 +0530)
committervignesh-chaturvedi <vigneshchaturvedi@gmail.com>
Mon, 26 Oct 2026 20:32:36 +0000 (02:02 +0530)
commitc6c84bf2b184918c8d31f7cd44ac57cdb8762297
treeb442164aedc80a8791f061ffdb4e2de6d306e180
parent9da20921c0a257d4d7ddd52de36bd3b75f3c8372
Don't destroy traces while they are being imported

If a trace was deleted while it was being imported, TraceDestroyerJob
could remove it and its points while TraceImporterJob was still adding
points, so the import failed the foreign key check and the owner was
emailed the full backtrace. If it happened after the last batch of
points, the import went on to attach the image and icon to the deleted
trace, and they were never removed.

TraceImporterJob now holds a key share lock on the trace while
importing it, and TraceDestroyerJob locks the trace before deleting
anything, so it waits for any import to finish. A key share lock
doesn't block other updates to the trace, so it can still be edited,
or marked as deleted, during the import.
app/jobs/trace_destroyer_job.rb
app/jobs/trace_importer_job.rb
test/jobs/trace_destroyer_job_test.rb
test/jobs/trace_importer_job_test.rb