I have a data-upload function that load some data into several tables and processes them. I want my users to be able to initiate two uploads at once (though this will be the exception rather than the rule), but in that instance I want the first upload to complete before the second upload begins. (The whole process should take around 20 seconds).
The reason for this is that if two uploads put data into the tables at the same time, then they'll interfere with one-another's data. (Side-note: I originally planned to use temp tables to achieve process isolation, but found I couldn't do that).
What's the best way to ensure that upload 2 waits until upload 1 is finished? I could create a table to use as a mutex and grab a lock on that table (or a known row) inside a transaction that wraps the whole process, but is there a cleaner or more efficient way to do it?