I'm looking for a way to queue incoming HTTP Post requests.
Apex REST API handlers are executed in parallel on separate threads. This introduces race conditions if any new records are inserted by the incoming HTTP requests.
I tried inserting the HTTP data into a custom object table for later processing by a trigger. Unfortunately, it looks like the trigger handler is spun out on independent threads, so I still have a race collision.
Does anyone know a way to ensure that a handler is executed only after all previous handlers have completed?
My current thought is to try to implement polling for completion of previous POSTs through the Queueable interface or with @future.
Does anyone have any guidance or thoughts? If you see an easier way, I'm eager to hear about it.
 If you don't see how unavoidable race conditions are created, post a comment and I will elaborate.  I'm already aware of the Known Issue Article "Race condition in Salesforce upsert operations may cause DUPLICATE_VALUE error" https://success.salesforce.com/issues_view?id=a1p300000008YBEAA2 The documented Workaround does not work for my situation.