elastic / elasticsearch-hadoop

:elephant: Elasticsearch real-time search and analytics natively integrated with Hadoop
https://www.elastic.co/products/hadoop
Apache License 2.0
1.93k stars 989 forks source link

Handling a race condition that can happen during index creation #2216

Closed masseyke closed 5 months ago

masseyke commented 5 months ago

As described in #2214, we have a race condition when two splits attempt to create an index at the same time. It is possible that the second split fails because it does not wait for shards to actually exist before attempting to use them. We only fetch shards in order to pick the node to write to, so it's not even necessary for the code to work (since any node will do). This change makes it so that if no shards exist we will just pick a random node to write to. Closes #2214