Possible race condition in create and delete APIs in DefaultStore
Description
Release Notes
Activity

Bhooshan Mogal December 4, 2014 at 8:19 PM
I don't think this will happen for all APIs. A lot of them are fine. As said, there could be a problem if APIs use two transactions. There could also be a problem if they catch a generic Exception and treat it as INTERNAL_SERVER_ERROR. Unsure of the exact APIs right now, but the way I implemented the namespace APIs, there was a race condition. If I come across possible such conditions again, I'll update this issue and create a PR. This issue is for tracking purposes.

Andreas Neumann December 4, 2014 at 8:10 PM
We do use transactions: one to check whether it exists. Another to perform the operation. They should be in a single transaction.
Regarding retries, completely agreed. It should auto-retry for conflicts, but not for other exceptions. We opened a Jira for Tephra. It currently retries on all TransactionFailureExceptions. But it should only retry for TransactionConflictException. All other TransactionFailureExceptions are just exceptions from the client's code that was wrapped in order to propagate it out of the transaction executor.

Alex Baranau December 4, 2014 at 7:50 PM
where is this in Store? Don't we use transactions in there?
Also, I don't think we should ever treat a transaction conflict as an error and propagate it to client code. It is not an error: it is bad timing;). It can be retried easily on server side. While requireing retrying on client side makes client unnecessary complex
Thoughts?
Details
Details
Assignee

Reporter

We need atomic test and set semantics in the create and delete APIs in Store. Currently, due to the race condition, the Http Handlers will get a TransactionFailureException, which to the client will propagate as
INTERNAL_SERVER_ERROR
. However, it should propagate to clients as eitherCONFLICT
orNOT_FOUND
.Assigning this to myself, and will implement a fix for namespaces immediately. Once namespaces is approved, I'll try and apply similar semantics to other entities as I go about changing all the APIs for namespace.