Skip to content

Commit 81c4163

Browse files
committed
Wait for active shards when hotswapping index
This ensures all the shards get the new index before we start streaming bulk queries.
1 parent efcc614 commit 81c4163

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/snap/indexes.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ defmodule Snap.Indexes do
169169
:ok | Cluster.error() | {:error, BulkError.t()}
170170
def hotswap(stream, cluster, alias, mapping, opts \\ []) do
171171
index = generate_index_name(alias)
172+
create_opts = [wait_for_active_shards: "all"]
172173

173-
with {:ok, _} <- create(cluster, index, mapping),
174+
with {:ok, _} <- create(cluster, index, mapping, create_opts),
174175
:ok <- Bulk.perform(stream, cluster, index, opts),
175176
:ok <- refresh(cluster, index),
176177
:ok <- alias(cluster, index, alias) do

0 commit comments

Comments
 (0)