Skip to content

[BUG] NullPointerException when restoring searchable snapshot created in Opensearch without shallow snapshots support #18187

@olddanmer

Description

@olddanmer

Describe the bug

After upgrading from OpenSearch 2.8 to OpenSearch 2.19, I can no longer restore searchable snapshots that were created using earlier Opensearch version. Restore process fails with a NullPointerException related to the isRemoteStoreIndexShallowCopyEnabled() field.

It seems that snapshots created with old OpenSearch versions (before 2.10???) do not contain the remote_store_index_shallow_copy field, and the current code does not handle its absence gracefully. This leads to a failure when restoring with storage_type: "remote_snapshot".

I can successfully restore snapshot

{
  "snapshots" : [
    {
      "snapshot" : "logstash-2025.03.01",
      "uuid" : "WUSPPQiuQc2od8PMyR5KTQ",
      "version_id" : 136407827,
      "version" : "2.19.0",
      "remote_store_index_shallow_copy" : false,
      "indices" : [
        "logstash-2025.03.01"
      ],
      "data_streams" : [ ],
      "include_global_state" : false,
      "state" : "SUCCESS",
      "start_time" : "2025-03-03T04:08:32.687Z",
      "start_time_in_millis" : 1740974912687,
      "end_time" : "2025-03-03T04:09:57.917Z",
      "end_time_in_millis" : 1740974997917,
      "duration_in_millis" : 85230,
      "failures" : [ ],
      "shards" : {
        "total" : 5,
        "failed" : 0,
        "successful" : 5
      }
    }
  ]
}

But cannot restore

{
  "snapshots" : [
    {
      "snapshot" : "logstash-2025.02.01",
      "uuid" : "CX4nReZiTrqtxZQsoh9wYg",
      "version_id" : 136297827,
      "version" : "2.8.0",
      "indices" : [
        "logstash-2025.02.01"
      ],
      "data_streams" : [ ],
      "include_global_state" : false,
      "state" : "SUCCESS",
      "start_time" : "2025-02-03T04:10:10.401Z",
      "start_time_in_millis" : 1738555810401,
      "end_time" : "2025-02-03T04:11:34.642Z",
      "end_time_in_millis" : 1738555894642,
      "duration_in_millis" : 84241,
      "failures" : [ ],
      "shards" : {
        "total" : 5,
        "failed" : 0,
        "successful" : 5
      }
    }
  ]
}

Related component

No response

To Reproduce

  1. Create a searchable snapshot using OpenSearch 2.8.

  2. Upgrade to OpenSearch 2.19.

  3. Attempt to restore the snapshot using the following request:

POST /_snapshot/s3_arch_repository/logstash-2025.02.01/_restore" -H 'Content-Type: application/json' -d'
    {
      "ignore_unavailable": true,
      "include_global_state": false,
      "include_aliases": false,
      "partial": false,
      "storage_type": "remote_snapshot"
    }'
  1. Observe the NullPointerException
{
  "error": {
    "root_cause": [
      {
        "type": "null_pointer_exception",
        "reason": "Cannot invoke \"java.lang.Boolean.booleanValue()\" because the return value of \"org.opensearch.snapshots.SnapshotInfo.isRemoteStoreIndexShallowCopyEnabled()\" is null"
      }
    ],
    "type": "null_pointer_exception",
    "reason": "Cannot invoke \"java.lang.Boolean.booleanValue()\" because the return value of \"org.opensearch.snapshots.SnapshotInfo.isRemoteStoreIndexShallowCopyEnabled()\" is null"
  },
  "status": 500
}

Expected behavior

Restoring searchable snapshots created in 2.8.0 is possible in Opensearch 2.19.0.

Additional Details

Plugins
opensearch-alerting
opensearch-anomaly-detection
opensearch-asynchronous-search
opensearch-cross-cluster-replication
opensearch-custom-codecs
opensearch-flow-framework
opensearch-geospatial
opensearch-index-management
opensearch-job-scheduler
opensearch-knn
opensearch-ltr
opensearch-ml
opensearch-neural-search
opensearch-notifications
opensearch-notifications-core
opensearch-observability
opensearch-performance-analyzer
opensearch-reports-scheduler
opensearch-security
opensearch-security-analytics
opensearch-skills
opensearch-sql
opensearch-system-templates
query-insights
repository-s3

Host/Environment (please complete the following information):

  • Version 2.19.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    ✅ Done

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions