Skip to content

Conversation

@gmarouli
Copy link
Contributor

Downsample transport action did not take into consideration the possibility of the target index being deleted when updating the downsample status. Although this is an unlikely event to happen without manual action, we should still return an appropriate error and not an NPE.

With this change, if someone deletes the target index after it was refreshed but before the downsample status has been updated they will receive the following error:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_state_exception",
        "reason": "Failed to update downsample status because [downsampled] does not exist"
      }
    ],
    "type": "illegal_state_exception",
    "reason": "Failed to update downsample status because [downsampled] does not exist"
  },
  "status": 500
}

We also reduced the places where we called recordSuccessMetrics. It was called also when we encountered a failure because we assumed that downsampling had successfully finished by then. However, if the index was deleted it would still count as a failure. I think it will be more clear to count as a success only when the transport action has successfully finished all processing steps.

Fixes: #137761

@gmarouli gmarouli added the :StorageEngine/Downsampling Downsampling (replacement for rollups) - Turn fine-grained time-based data into coarser-grained data label Nov 19, 2025
@elasticsearchmachine elasticsearchmachine added Team:StorageEngine and removed needs:triage Requires assignment of a team area label labels Nov 19, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @gmarouli, I've created a changelog YAML for you.

@elasticsearchmachine
Copy link
Collaborator

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

@gmarouli gmarouli requested a review from martijnvg November 19, 2025 10:50
@gmarouli
Copy link
Contributor Author

Thank you @kkrik-es

@gmarouli gmarouli merged commit 14f5892 into elastic:main Nov 19, 2025
34 checks passed
@gmarouli gmarouli deleted the fix-downsampled-being-deleted branch November 19, 2025 10:53
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
9.2 Commit could not be cherrypicked due to conflicts
8.19 Commit could not be cherrypicked due to conflicts
9.1 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 138228

gmarouli added a commit to gmarouli/elasticsearch that referenced this pull request Nov 19, 2025
…ted unexpectedly. (elastic#138228)

(cherry picked from commit 14f5892)

# Conflicts:
#	x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java
gmarouli added a commit to gmarouli/elasticsearch that referenced this pull request Nov 19, 2025
…ted unexpectedly. (elastic#138228)

(cherry picked from commit 14f5892)

# Conflicts:
#	x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java
@gmarouli
Copy link
Contributor Author

💔 Some backports could not be created

Status Branch Result
9.2
9.1
8.19 An unhandled error occurred. Please see the logs for details

Manual backport

To create the backport manually run:

backport --pr 138228

Questions ?

Please refer to the Backport tool documentation

gmarouli added a commit to gmarouli/elasticsearch that referenced this pull request Nov 19, 2025
…ted unexpectedly. (elastic#138228)

(cherry picked from commit 14f5892)

# Conflicts:
#	x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java
gmarouli added a commit to gmarouli/elasticsearch that referenced this pull request Nov 20, 2025
…ted unexpectedly. (elastic#138228)

(cherry picked from commit 14f5892)

# Conflicts:
#	x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java
#	x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java
@gmarouli
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Questions ?

Please refer to the Backport tool documentation

gmarouli added a commit that referenced this pull request Nov 20, 2025
gmarouli added a commit that referenced this pull request Nov 20, 2025
gmarouli added a commit that referenced this pull request Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged backport pending >bug :StorageEngine/Downsampling Downsampling (replacement for rollups) - Turn fine-grained time-based data into coarser-grained data Team:StorageEngine v8.19.8 v9.1.8 v9.2.2 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE in downsample transport action

3 participants