Shakirov Ramil
Shakirov Ramil

Reputation: 1543

Is opensearch index should deleted after shrink?

I have an ISL policy for my index. It's move index state to state. On the last policy state of shrinking shard I'm expecting that old index would be deleted, but I still see the old one.

GET http://localhost:9200/_cat/indices

HTTP/1.1 200 OK
content-type: text/plain; charset=UTF-8

green open businesslog-longterm-000001_shrunken m6nVneoYSRyoPxulpN6Hkg 2 1 725   0   815kb 407.5kb
green open businesslog-longterm-000001          3Ns6iCjuQJySHMC-o63atw 4 1 725   0 816.3kb 408.1kb

Is opensearch should deleted old index after shrink?

test cluster policy looks like:

PUT http://localhost:9200/_plugins/_ism/policies/businesslog-longterm-policy
Content-Type: application/json

{
  "policy": {
    "description": "BusinessLog LONG-TERM policy",
    "default_state": "hot",
    "states": [
      {
        "name": "hot",
        "actions": [
          {
            "rollover": {
              "min_doc_count": "200"
            },
            "retry": {
              "count": 3,
              "backoff": "exponential",
              "delay": "1m"
            }
          },
          {
            "index_priority": {
              "priority": 100
            }
          }
        ],
        "transitions": [
          {
            "state_name": "warm",
            "conditions": {
              "min_rollover_age": "15m"
            }
          }
        ]
      },
      {
        "name": "warm",
        "actions": [
          {
            "force_merge": {
              "max_num_segments": 1
            },
            "retry": {
              "count": 3,
              "backoff": "exponential",
              "delay": "1m"
            }
          },
          {
            "index_priority": {
              "priority": 50
            }
          }
        ],
        "transitions": [
          {
            "state_name": "cold",
            "conditions": {
              "min_rollover_age": "10m"
            }
          }
        ]
      },
      {
        "name": "cold",
        "actions": [
          {
            "shrink": {
              "num_new_shards": 2,
              "target_index_name_template": {
                "source": "{{ctx.index}}_shrunken",
                "lang": "mustache"
              },
              "force_unsafe": true
            }
          },
          {
            "index_priority": {
              "priority": 0
            }
          }
        ],
        "transitions": [
        ]
      }
    ],
    "ism_template": {
      "index_patterns": ["businesslog-longterm*"],
      "priority": 100
    }
  }
}

Upvotes: 0

Views: 105

Answers (1)

ANKUSH KUMAR GIRI
ANKUSH KUMAR GIRI

Reputation: 1

No, deleting the OpenSearch index after shrinking is not required, but it depends on your use case and the specific context. Let's break down the scenario:

What is Index Shrinking in OpenSearch? Index shrinking is a process that allows you to reduce the number of primary shards in an index to make it more efficient. This is typically done when:

An index has grown large with many shards, and you want to optimize storage or improve query performance. You no longer need to keep the original number of primary shards because the index is no longer actively growing or being written to, but you still want to keep it for historical data. The shrinking process in OpenSearch involves:

Creating a new index with fewer primary shards. Reindexing data from the old index into the new one. Deleting the old index (optional, depending on whether you want to save space or not). Should You Delete the Index After Shrinking? After you shrink an index, you don't have to delete the original index immediately unless:

You no longer need the original index: If you’ve reindexed the data into a smaller, more efficient index and you no longer require the old index, you can delete it to free up storage space. You want to optimize disk usage: Deleting the old index after shrinking will save storage if the original index had many unused or fragmented shards. However, if you still need the original index for reference, backup, or other purposes, you can retain it. Just keep in mind that it may occupy significant storage depending on how much data was reindexed and how many shards are in the original index.

Considerations: Backup: Before deleting the original index, ensure you have a backup if it contains important data or if the shrinking process was part of a migration. Cluster Performance: After shrinking, if you no longer need the original index, deleting it can help improve cluster performance by freeing up resources. Snapshot: It’s a good practice to take a snapshot of the index before deleting it, especially if it contains important or historical data

Upvotes: -1

Related Questions