Skip to content

Commit

Permalink
Register TopN status in plugin's writables (elastic#100874)
Browse files Browse the repository at this point in the history
```
"node_failures": [
  {
    "type": "failed_node_exception",
    "reason": "Failed node [qpdSPb3yQkuDlsI9TH7a2g]",
    "node_id": "qpdSPb3yQkuDlsI9TH7a2g",
    "caused_by": {
      "type": "transport_serialization_exception",
      "reason": "Failed to deserialize response from handler",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "Unknown NamedWriteable [org.elasticsearch.compute.operator.Operator$Status][topn]"
      }
    }
  }
]
```

I hit this error when trying to retrieve ESQL tasks. The issue is that we forget
 to register NamedWritable for the status of TopN.
  • Loading branch information
dnhatn committed Oct 16, 2023
1 parent 33ed412 commit 954f2a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.compute.data.Block;
import org.elasticsearch.compute.data.BlockFactory;
import org.elasticsearch.compute.lucene.LuceneSourceOperator;
import org.elasticsearch.compute.lucene.LuceneOperator;
import org.elasticsearch.compute.lucene.ValuesSourceReaderOperator;
import org.elasticsearch.compute.operator.AbstractPageMappingOperator;
import org.elasticsearch.compute.operator.DriverStatus;
Expand All @@ -32,6 +32,7 @@
import org.elasticsearch.compute.operator.exchange.ExchangeService;
import org.elasticsearch.compute.operator.exchange.ExchangeSinkOperator;
import org.elasticsearch.compute.operator.exchange.ExchangeSourceOperator;
import org.elasticsearch.compute.operator.topn.TopNOperatorStatus;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.indices.IndicesService;
Expand Down Expand Up @@ -155,7 +156,8 @@ public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
ExchangeSinkOperator.Status.ENTRY,
ExchangeSourceOperator.Status.ENTRY,
LimitOperator.Status.ENTRY,
LuceneSourceOperator.Status.ENTRY,
LuceneOperator.Status.ENTRY,
TopNOperatorStatus.ENTRY,
MvExpandOperator.Status.ENTRY,
ValuesSourceReaderOperator.Status.ENTRY,
SingleValueQuery.ENTRY
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.esql.action;

import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.compute.operator.Operator;
import org.elasticsearch.compute.operator.topn.TopNOperatorStatus;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.esql.plugin.EsqlPlugin;

import static org.hamcrest.Matchers.equalTo;

public class NamedWriteablesTests extends ESTestCase {

public void testTopNStatus() throws Exception {
try (EsqlPlugin plugin = new EsqlPlugin()) {
NamedWriteableRegistry registry = new NamedWriteableRegistry(plugin.getNamedWriteables());
TopNOperatorStatus origin = new TopNOperatorStatus(randomNonNegativeInt(), randomNonNegativeLong());
TopNOperatorStatus copy = (TopNOperatorStatus) copyNamedWriteable(origin, registry, Operator.Status.class);
assertThat(copy.occupiedRows(), equalTo(origin.occupiedRows()));
assertThat(copy.ramBytesUsed(), equalTo(origin.ramBytesUsed()));
}
}
}

0 comments on commit 954f2a0

Please sign in to comment.