Skip to content

Incorrect took time in Bulk request #129894

Open
@syhily

Description

@syhily

Elasticsearch Version

8.18.2

Installed Plugins

No response

Java Version

bundled

OS Version

Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:49 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6000 arm64

Problem Description

In #111863 the TransportAbstractBulkAction was using ThreadPool::relativeTimeInNanos to get the start time, and then subtracting that from the ThreadPool::relativeTimeInNanos of the finish time to compute the took time. Given the ThreadPool::relativeTimeInNanos is updated by a fixed thead in 200ms interval by default. So the took time was not correct (sometimes it's even 0) as expected in standalone Elasticsearch cluster.

Steps to Reproduce

Open an elk standalone cluster. Using the command like below.

PUT /bulk-took-test

PUT /bulk-took-test/_bulk
{ "index" : { "_index" : "bulk-took-test", "_id" : "1" } }
{ "field1" : "value1" }

The response could be the json like below. And the took time is zero.

{
  "errors": false,
  "took": 0,
  "items": [
    {
      "index": {
        "_index": "bulk-took-test",
        "_id": "1",
        "_version": 1,
        "result": "created",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "_seq_no": 0,
        "_primary_term": 1,
        "status": 201
      }
    }
  ]
}

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    >bug>docsGeneral docs changesTeam:DocsMeta label for docs team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions