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:
PUT idx1
PUT idx1/t1/1
{
"name": "foo"
}
PUT idx1/t1/2
{
"name": "bar"
}
POST idx1/_refresh
POST idx1/_flush/synced
GET idx1/_stats/store,docs,indexing?filter_path=indices
In the response of the last command, value of "indices.idx1.primaries.store.size_in_bytes
" is 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.