We have some tests which query the index size from Elasticsearch and perform some validations on it. This validation is flaky - it does not pass always. Below is the reproduction:
Execute all commands below in one go:
In the response of the last command, value of
261. If I execute the last command repeatedly for a few seconds, it eventually increases and settles at
7793. Funny thing is if I delete the index
idx1 and execute all the commands above, I get the value
7793 in the very first attempt. If I repeat this with a new index name, the bug reproduces. This leads me to believe there is some caching going on in the background. I want to know if there a way to get to the final state reliably and synchronously instead of polling. Maybe I need to execute more commands. Please help.