Elasticsearch version (bin/elasticsearch --version):
Version: 8.1.0-SNAPSHOT, Build: default/tar/e38cadb5283feeea06f09d555dbe47fb1d5e8b39/2021-11-22T22:35:22.825882Z, JVM: 17.0.1
OS version (uname -a if on a Unix-like system):
Darwin 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64
Description of the problem including expected versus actual behavior:
I expect ES to reject snapshot restore requests that restore a data stream alias with the same name as an existing data stream or index.
However, ES currently accepts these requests. This cluster now has a data stream/index and alias with the same name. A user may not be sure which resource a search request targeting the name will hit.
Steps to reproduce:
- Register a snapshot repository
PUT /_snapshot/my_repository
{
"type": "fs",
"settings": {
"location": "my_backup_location"
}
}
- Create a data stream.
POST logs-my_app-default/_doc
{
"@timestamp": "2099-05-06T16:21:15.000Z"
}
- Add a
logs alias to the data stream.
POST _aliases
{
"actions": [
{
"add": {
"index": "logs-my_app-default",
"alias": "logs"
}
}
]
}
- Create a snapshot containing the data stream and its alias
PUT _snapshot/my_repository/my_snapshot?wait_for_completion=true
- Delete the data stream. This also deletes the alias.
DELETE _data_stream/logs-my_app-default
- Create another data stream with same name as the deleted alias (
logs).
PUT _index_template/my-index-template
{
"index_patterns": ["logs"],
"data_stream": { },
"priority": 500
}
POST logs/_doc
{
"@timestamp": "2099-05-07T16:21:15.000Z"
}
- Restore the data stream and
logs alias from the snapshot.
POST /_snapshot/my_repository/my_snapshot/_restore?wait_for_completion=true
{
"indices": "logs-my_app-default",
"include_aliases": true
}
I expected this to return an error due to a conflict between the restored logs
alias and the pre-existing logs data stream. However, the request was
accepted, and both resources now exist.
Retrieve the logs data stream:
Retrieve the logs alias:
A search on logs only hits the logs data stream:
However, a search on log* hits both the alias and the data stream:
Elasticsearch version (
bin/elasticsearch --version):Version: 8.1.0-SNAPSHOT, Build: default/tar/e38cadb5283feeea06f09d555dbe47fb1d5e8b39/2021-11-22T22:35:22.825882Z, JVM: 17.0.1
OS version (
uname -aif on a Unix-like system):Darwin 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64
Description of the problem including expected versus actual behavior:
I expect ES to reject snapshot restore requests that restore a data stream alias with the same name as an existing data stream or index.
However, ES currently accepts these requests. This cluster now has a data stream/index and alias with the same name. A user may not be sure which resource a search request targeting the name will hit.
Steps to reproduce:
logsalias to the data stream.logs).logsalias from the snapshot.I expected this to return an error due to a conflict between the restored
logsalias and the pre-existing
logsdata stream. However, the request wasaccepted, and both resources now exist.
Retrieve the
logsdata stream:Retrieve the
logsalias:A search on
logsonly hits thelogsdata stream:However, a search on
log*hits both the alias and the data stream: