Please help to confirm: even with upsert API, there could still happen data override

let's say we have 2 threads to upsert one document with same uid
is it possible that both threads cound identify its a fresh newly doc and both execute insert operation, which will cause one thread override the other's data.

please help to verify if this could happen because I met some problem that only with the explaination could make sense whole things.

thanks.

@jpountz
@Christian_Dahlqvist
can you guys help to share anything useful?

No this can't happen, you will get an error saying that there was a conflict in that case. You can tell elasticsearch to retry in that case with the retry_on_conflict parameter https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_parameters_3