Skip to content

Snapshot Restoration Causes a NullPointerException on Indices that Include a Null Timestamp Default #9426

@chrisguitarguy

Description

@chrisguitarguy

I have a field with a null default _timestamp value and when I try to restore from a snapshot I get a server error caused by a NullPointerException.

Looks like the default timestamp value is not checked to see if it's null: https://github.com/elasticsearch/elasticsearch/blob/v1.4.2/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java#L358

I had another issue with a similar thing (#9204), maybe there's other timestamp related bugs floating around?

Stack trace:

[2015-01-26 14:55:09,604][WARN ][snapshots                ] [Gamora] [example][snap1] failed to restore snapshot
java.lang.NullPointerException
    at org.elasticsearch.cluster.metadata.MappingMetaData.initMappers(MappingMetaData.java:358)
    at org.elasticsearch.cluster.metadata.MappingMetaData.<init>(MappingMetaData.java:307)
    at org.elasticsearch.cluster.metadata.IndexMetaData$Builder.fromXContent(IndexMetaData.java:666)
    at org.elasticsearch.repositories.blobstore.BlobStoreRepository.readSnapshotMetaData(BlobStoreRepository.java:451)
    at org.elasticsearch.repositories.blobstore.BlobStoreRepository.readSnapshotMetaData(BlobStoreRepository.java:392)
    at org.elasticsearch.snapshots.RestoreService.restoreSnapshot(RestoreService.java:122)
    at org.elasticsearch.action.admin.cluster.snapshots.restore.TransportRestoreSnapshotAction.masterOperation(TransportRestoreSnapshotAction.java:78)
    at org.elasticsearch.action.admin.cluster.snapshots.restore.TransportRestoreSnapshotAction.masterOperation(TransportRestoreSnapshotAction.java:41)
    at org.elasticsearch.action.support.master.TransportMasterNodeOperationAction$3.run(TransportMasterNodeOperationAction.java:134)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

To reproduce:

# sample index
$curl -XPOST localhost:9200/twitter -d '{
>     "mappings": {
>         "tweet": {
>             "_timestamp": {
>                 "enabled": true,
>                 "default": null
>             }
>         }
>     }
> }'
# {"acknowledged":true}

# create a snapshot
$ curl -XPUT localhost:9200/_snapshot/example/snap1
# {"accepted":true}

# make sure our snapshot is done
$ curl -XGET localhost:9200/_snapshot/example/_all?pretty
{
  "snapshots" : [ {
    "snapshot" : "snap1",
    "indices" : [ "twitter" ],
    "state" : "SUCCESS",
    "start_time" : "2015-01-26T19:48:31.941Z",
    "start_time_in_millis" : 1422301711941,
    "end_time" : "2015-01-26T19:48:31.979Z",
    "end_time_in_millis" : 1422301711979,
    "duration_in_millis" : 38,
    "failures" : [ ],
    "shards" : {
      "total" : 5,
      "failed" : 0,
      "successful" : 5
    }
  } ]
}

# Close the index so we can restore it
$ curl -XPOST localhost:9200/twitter/_close
# {"acknowledged":true}

# try to restore
curl -XPOST localhost:9200/_snapshot/example/snap1/_restore
# {"error":"NullPointerException[null]","status":500}

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