Skip to content

Open PIT swaps skipped & failed _shards results #131026

@benchaplin

Description

@benchaplin

Elasticsearch Version

9.1.0-SNAPSHOT

Installed Plugins

No response

Java Version

bundled

OS Version

N/A

Problem Description

Open PIT request returns the number of failed shards in the "skipped" field and the number of skipped shards in the "failed" field.

Looks like the bug has been in place since partial search was added to PIT (#111516).

I believe the fix is just to pass values in the correct order here:

buildBroadcastShardsHeader(builder, params, totalShards, successfulShards, failedShards, skippedShards, null);

public static XContentBuilder buildBroadcastShardsHeader(
XContentBuilder builder,
Params params,
int total,
int successful,
int skipped,
int failed,
ShardOperationFailedException[] shardFailures
) throws IOException {

Though we also clearly need to fill a gap in testing.

Steps to Reproduce

  1. Start a 2 node cluster
  2. Put an index with 2 shards
PUT /test
{
    "settings": {
        "index": {
            "number_of_shards": 2,
            "number_of_replicas": 0
        }
    }
}
  1. Stop one of the nodes (therefore making a shard unavailable).
  2. Open a PIT allowing partial search results
POST /test/_pit?keep_alive=1m&allow_partial_search_results=true
-> {
  "id": "...",
  "_shards": {
    "total": 2,
    "successful": 1,
    "skipped": 1,
    "failed": 0
  }
}

There should be 1 shard failed, not 1 skipped. For instance, a normal search gives:

GET /test/_search
-> {
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 2,
    "successful": 1,
    "skipped": 0,
    "failed": 1,
    "failures": [
      {
        "shard": 1,
        "index": "test",
        "node": null,
        "reason": {
          "type": "no_shard_available_action_exception",
          "reason": null
        }
      }
    ]
  },
  "hits": {
    "total": {
      "value": 0,
      "relation": "eq"
    },
    "max_score": null,
    "hits": []
  }
}

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions