Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datastream temporal_ranges is wrong in presence of downsampling #106890

Open
lkts opened this issue Mar 28, 2024 · 4 comments
Open

Datastream temporal_ranges is wrong in presence of downsampling #106890

lkts opened this issue Mar 28, 2024 · 4 comments
Labels
>bug :Data Management/Data streams Data streams and their lifecycles :StorageEngine/TSDB You know, for Metrics Team:Data Management Meta label for data/management team Team:StorageEngine

Comments

@lkts
Copy link
Contributor

lkts commented Mar 28, 2024

Elasticsearch Version

8.14

Installed Plugins

No response

Java Version

bundled

OS Version

all

Problem Description

Original issue i noticed - every execution of a request like GET /_data_stream/my-data-stream for TSDS with downsampling enabled produces a warning of format previous backing index [..] range [..] range is colliding with current backing [..] index range [..].

While looking at this issue i realized that it looks like temporal_ranges information for data stream is wrong. See logs section for details.

Additionally the log is misleading - information it provides is incorrect, start and end times of indices reported are not actual start and end time for this index.

Steps to Reproduce

  1. Create a TSDS with downsampling enabled
  2. Create at least two downsampled indices using rollover or ILM

Logs (if relevant)

Example

previous backing index [downsample-5m-.ds-my-data-stream-2024.03.27-000002] range [2024-03-27T21:34:37Z/2024-03-27T22:19:05Z] range is colliding with current backing [downsample-5m-.ds-my-data-stream-2024.03.27-000001] index range [2024-03-27T19:04:37Z/2024-03-27T21:34:37Z]

Datastream information (relevant parts):

"indices" : [
        {
          "index_name" : "downsample-5m-.ds-my-data-stream-2024.03.27-000002",
          "index_uuid" : "i40UG4WGSa-EEgqlxmmQKA",
          "prefer_ilm" : true,
          "managed_by" : "Data stream lifecycle"
        },
        {
          "index_name" : "downsample-5m-.ds-my-data-stream-2024.03.27-000001",
          "index_uuid" : "3PozqIHaQ-W1vJkNZAX3bA",
          "prefer_ilm" : true,
          "managed_by" : "Data stream lifecycle"
        },
        {
          "index_name" : ".ds-my-data-stream-2024.03.27-000003",
          "index_uuid" : "Et2kbilgRUi13_kIh6md0w",
          "prefer_ilm" : true,
          "managed_by" : "Data stream lifecycle"
        },
        {
          "index_name" : ".ds-my-data-stream-2024.03.28-000008",
          "index_uuid" : "VKhQEQekSFKxgexV_xOFeQ",
          "prefer_ilm" : true,
          "managed_by" : "Data stream lifecycle"
        }
      ],
............
"time_series" : {
        "temporal_ranges" : [
          {
            "start" : "2024-03-27T21:34:37.000Z",
            "end" : "2024-03-28T19:44:39.000Z"
          }
        ]
      }

Time ranges of indices:

downsample-5m-.ds-my-data-stream-2024.03.27-000002:

"time_series" : {
  "end_time" : "2024-03-27T22:19:05.000Z",
  "start_time" : "2024-03-27T21:34:37.000Z"
},

downsample-5m-.ds-my-data-stream-2024.03.27-000001

"time_series" : {
  "end_time" : "2024-03-27T21:34:37.000Z",
  "start_time" : "2024-03-27T19:04:37.000Z"
},

.ds-my-data-stream-2024.03.27-000003

"time_series" : {
  "end_time" : "2024-03-28T19:14:39.000Z",
  "start_time" : "2024-03-27T22:19:05.000Z"
},

.ds-my-data-stream-2024.03.28-000008

"time_series" : {
  "end_time" : "2024-03-28T19:52:02.000Z",
  "start_time" : "2024-03-28T19:14:39.000Z"
},

We can see that temporal_ranges is wrong. start is 2024-03-27T21:34:37.000Z which is a start time of *000002 index instead of index *000001 with an earlier range. It is likely caused by the order of indices, we probably assume ascending ordering based on time series start and end. It seems like this is not true with downsampling and the root cause is somewhere where we replace backing index of datastream.

@lkts lkts added >bug needs:triage Requires assignment of a team area label :StorageEngine/TSDB You know, for Metrics Team:StorageEngine labels Mar 28, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Mar 28, 2024
@lkts lkts added the :Data Management/Data streams Data streams and their lifecycles label Mar 28, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Mar 28, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@lkts
Copy link
Contributor Author

lkts commented Mar 28, 2024

This is because of this logic

which calls DataStream#addBackingIndex that does backingIndices.add(0, index);. This is why downsampled indices are always at the top.

@lkts
Copy link
Contributor Author

lkts commented Mar 28, 2024

ILM works correctly since it uses

ReplaceDataStreamBackingIndexStep replaceDataStreamBackingIndex = new ReplaceDataStreamBackingIndexStep(
which correctly performs DataStream#replaceBackingIndex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Data Management/Data streams Data streams and their lifecycles :StorageEngine/TSDB You know, for Metrics Team:Data Management Meta label for data/management team Team:StorageEngine
Projects
None yet
Development

No branches or pull requests

2 participants