olivere / elastic

Deprecated: Use the official Elasticsearch client for Go at https://github.com/elastic/go-elasticsearch
https://olivere.github.io/elastic/
MIT License
7.39k stars 1.15k forks source link

Issue with Elasticsearch Alias Removal and Addition #1681

Open younuscodes opened 7 months ago

younuscodes commented 7 months ago

Which version of Elastic are you using?

[x] elastic.v6 (for Elasticsearch 6.2.4)

Please describe the expected behavior

The removeAliasIndex function should consistently return accurate acknowledgment status (res.Acknowledged = true) when successfully removing an alias. This behavior is crucial for ensuring reliable subsequent operations, such as adding a new index to the alias.

Please describe the actual behavior

The removeAliasIndex function sometimes returns res.Acknowledged = false even when the alias removal is successful. This intermittent behavior poses challenges when attempting to add a new index to the alias, as the acknowledgment status does not accurately reflect the success of the removal operation. Additionally, there are instances where the call returns res.Acknowledged == false, but the index is deleted after some time.

Any steps to reproduce the behavior?

The issue seems to occur intermittently, making it challenging to provide specific steps to reproduce. The problem is observed in a production environment. Additional Information

Elasticsearch version: 6.2.4

Note

Any insights or recommendations on resolving this issue would be greatly appreciated. Please consider the Elasticsearch version mentioned and provide guidance accordingly. Thank you!

code: // Function to remove alias index func removeAliasIndex(isHttps bool, host, indexName, aliasName string) error { // ... (existing code)

res, err := esClient.Alias().Remove(indexName, aliasName).Do(context.Background()) // some time this call returns res.Acknowledged == false but actually it delete index after some time
if err != nil {
    return err
}

// ... (existing code)

}

// Function to add alias index func addAliasIndex(isHttps bool, host, indexName, aliasName string) error { // ... (existing code)

res, err := esClient.Alias().Add(indexName, aliasName).Do(context.Background())
if err != nil {
    return err
}

// ... (existing code)

}