Skip to content

RestElasticSearchClient.clearStore does not lowercase the store name, so DISCARD_INDEX cannot delete data for mixed-case index names #4929

Description

@batrived
  • Version: master (ac0eb23)
  • Storage Backend: any
  • Mixed Index Backend: elasticsearch
  • Expected Behavior: mgmt.updateIndex(index, SchemaAction.DISCARD_INDEX) on a mixed index deletes the backing Elasticsearch index.
  • Current Behavior: for any mixed index whose name contains an uppercase character, it targets an index name that cannot exist, so the data is never deleted.

Details

Every read and write path derives the Elasticsearch index name through generateIndexStoreName, which lowercases the store:

* @param config a config passed to ElasticSearchIndex's constructor
* @return a client object open and ready for use
*/

private String generateIndexStoreName(String store){
    return indexName + INDEX_NAME_SEPARATOR + store.toLowerCase();
}

clearStore composes the same name by hand, and does not:

public void clearStore(String indexName, String storeName) throws IOException {
String name = indexName + "_" + storeName;
if (indexExists(name)) {
performRequest(REQUEST_TYPE_DELETE, REQUEST_SEPARATOR + indexName + "_" + storeName, null);
}
}

public void clearStore(String indexName, String storeName) throws IOException {
    String name = indexName + "_" + storeName;          // no toLowerCase()
    if (indexExists(name)) {
        performRequest(REQUEST_TYPE_DELETE, REQUEST_SEPARATOR + indexName + "_" + storeName, null);
    }
}

A mixed index's store name is its JanusGraph index name verbatim (createMixedIndex sets INDEXSTORE_NAME = indexName), and index names are case-sensitive on the JanusGraph side. So for mgmt.buildIndex("vertexByName", Vertex.class).buildMixedIndex(...):

written and queried as <indexName>_vertexbyname
clearStore targets <indexName>_vertexByName

Since Elasticsearch requires lowercase index names, the second cannot exist. Either indexExists returns false and the call silently no-ops, or ES rejects the invalid name and ManagementSystem reports the misleading "Index removal is not supported for this Backend. Index must be removed in the indexing system directly." Either way the documents remain and the schema is marked DISCARDED, so JanusGraph believes the data is gone.

Related, and worth considering separately: because generateIndexStoreName lowercases, two mixed indexes differing only in case (byName and byname) map to the same Elasticsearch index and silently share documents. ManagementSystem.checkIndexName only enforces uniqueness on the JanusGraph side.

Steps to Reproduce

  1. Create a mixed index with an uppercase character in its name, e.g. vertexByName, and index some vertices.
  2. mgmt.updateIndex(mgmt.getGraphIndex("vertexByName"), SchemaAction.DISCARD_INDEX), then commit.
  3. Observe: the schema status becomes DISCARDED, and GET _cat/indices still shows <indexName>_vertexbyname with all its documents.

Suggested Fix

String name = indexName + "_" + storeName.toLowerCase();

applied to both the existence check and the delete path. Better still, have ElasticSearchIndex pass the already-derived name so the mapping exists in exactly one place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions