# Elasticsearch SQL ODBC Driver error of all shards failed

**URL:** https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448
**Category:** Elasticsearch
**Tags:** elastic-stack-sql
**Created:** [March 26, 2021, 7:27am UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448 "2021-03-26T07:27:12Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![onkark](https://avatars.discourse-cdn.com/v4/letter/o/bbce88/32.png) [@onkark](https://discuss.elastic.co/u/onkark)
#### Post date: [March 26, 2021, 7:27am UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/1 "2021-03-26T07:27:13Z")

</div>

I'm using Elasticsearch Odbc as driver between my C++ code and Elasticsearch engine. When firing sql select query, the shards are getting failed. Please help me through this.  
Thanks in advance.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 26, 2021, 7:51am UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/2 "2021-03-26T07:51:52Z")

</div>

You need to provide the exact and full message and the logs.

---

<div class="post-metadata">

### Author: ![onkark](https://avatars.discourse-cdn.com/v4/letter/o/bbce88/32.png) [@onkark](https://discuss.elastic.co/u/onkark)
#### Post date: [March 31, 2021, 5:25am UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/3 "2021-03-31T05:25:46Z")

</div>

[2021-03-30T15:42:04,127][INFO][o.e.g.GatewayService] [IXPUNDEVDESK02] recovered [18] indices into cluster\_state  
[2021-03-30T15:42:11,070][INFO][o.e.c.r.a.AllocationService] [IXPUNDEVDESK02] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[.apm-agent-configuration][0]]]).  
[2021-03-30T15:42:41,376][INFO][o.e.c.m.MetaDataIndexTemplateService] [IXPUNDEVDESK02] adding template [.management-beats] for index patterns [.management-beats]  
[2021-03-30T16:04:23,454][WARN][r.suppressed] [IXPUNDEVDESK02] path: /\_sql, params: {}  
org.elasticsearch.xpack.sql.SqlIllegalArgumentException: Unexpected failure decoding cursor  
at org.elasticsearch.xpack.sql.session.Cursors.decodeFromStringWithZone(Cursors.java:97) ~[?:?]  
at org.elasticsearch.xpack.sql.plugin.TransportSqlQueryAction.operation(TransportSqlQueryAction.java:85) ~[?:?]  
at org.elasticsearch.xpack.sql.plugin.TransportSqlQueryAction.doExecute(TransportSqlQueryAction.java:67) ~[?:?]  
at org.elasticsearch.xpack.sql.plugin.TransportSqlQueryAction.doExecute(TransportSqlQueryAction.java:45) ~[?:?]  
at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:153) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.apply(SecurityActionFilter.java:123) ~[?:?]  
at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:151) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:129) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:64) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.client.node.NodeClient.executeLocally(NodeClient.java:94) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:83) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:396) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.sql.plugin.RestSqlQueryAction.lambda$prepareRequest$0(RestSqlQueryAction.java:106) ~[?:?]  
at org.elasticsearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:108) [elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.security.rest.SecurityRestFilter.handleRequest(SecurityRestFilter.java:75) [x-pack-security-7.6.2.jar:7.6.2]  
at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:227) [elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.rest.RestController.tryAllHandlers(RestController.java:309) [elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:167) [elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.http.AbstractHttpServerTransport.dispatchRequest(AbstractHttpServerTransport.java:322) [elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.http.AbstractHttpServerTransport.handleIncomingRequest(AbstractHttpServerTransport.java:372) [elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.http.AbstractHttpServerTransport.incomingRequest(AbstractHttpServerTransport.java:301) [elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.http.netty4.Netty4HttpRequestHandler.channelRead0(Netty4HttpRequestHandler.java:54) [transport-netty4-client-7.6.2.jar:7.6.2]  
at org.elasticsearch.http.netty4.Netty4HttpRequestHandler.channelRead0(Netty4HttpRequestHandler.java:29) [transport-netty4-client-7.6.2.jar:7.6.2]  
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at org.elasticsearch.http.netty4.Netty4HttpPipeliningHandler.channelRead(Netty4HttpPipeliningHandler.java:58) [transport-netty4-client-7.6.2.jar:7.6.2]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-codec-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [netty-codec-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-codec-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-codec-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:326) [netty-codec-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:300) [netty-codec-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287) [netty-handler-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:600) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:554) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) [netty-transport-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) [netty-common-4.1.43.Final.jar:4.1.43.Final]  
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.43.Final.jar:4.1.43.Final]  
at java.lang.Thread.run(Thread.java:748) [?:1.8.0\_281]  
Caused by: java.io.EOFException: tried to read: 6146 bytes but this stream is limited to: 2997  
at org.elasticsearch.common.io.stream.InputStreamStreamInput.ensureCanReadBytes(InputStreamStreamInput.java:121) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.common.io.stream.FilterStreamInput.ensureCanReadBytes(FilterStreamInput.java:80) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.common.io.stream.StreamInput.readArraySize(StreamInput.java:1238) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.common.io.stream.StreamInput.readArrayList(StreamInput.java:753) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.common.io.stream.StreamInput.readGenericValue(StreamInput.java:696) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.sql.session.ListCursor.(ListCursor.java:38) ~[?:?]  
at org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput.readNamedWriteable(NamedWriteableAwareStreamInput.java:46) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput.readNamedWriteable(NamedWriteableAwareStreamInput.java:39) ~[elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.sql.session.Cursors.decodeFromStringWithZone(Cursors.java:94) ~[?:?]  
... 64 more

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 31, 2021, 6:22am UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/4 "2021-03-31T06:22:43Z")

</div>

Could you update your version to 7.12.0 to check if the problem is still there?

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

---

<div class="post-metadata">

### Author: ![bogdan.pintea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bogdan.pintea/32/45740_2.png) [@bogdan.pintea](https://discuss.elastic.co/u/bogdan.pintea)
#### Post date: [April 1, 2021, 12:01pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/5 "2021-04-01T12:01:38Z")

</div>

~~To address the question first the following two log lines hint that there might be an issue with your strings handling: could it be that the value of the `cursor` attribute you receive in a response is not the same as the one you send in the subsequent request?~~

Edit: to rule out a corruption in the app,

~~I guess that should be easy to troubleshoot in your app, but in case you think the issue lies somewhere else,~~ you could enable driver's own **DEBUG** logging, as [documented here](https://www.elastic.co/guide/en/elasticsearch//reference/7.6/sql-odbc-setup.html#_2_5_logging_parameters) (note the **Enable driver logging** section) and share those logs.

> [@onkark](#):
>
> org.elasticsearch.xpack.sql.SqlIllegalArgumentException: Unexpected failure decoding cursor  
> at org.elasticsearch.xpack.sql.session.Cursors.decodeFromStringWithZone(Cursors.java:97) ~[?:?]  
> [...]  
> Caused by: java.io.EOFException: tried to read: 6146 bytes but this stream is limited to: 2997  
> at org.elasticsearch.common.io.stream.InputStreamStreamInput.ensureCanReadBytes(InputStreamStreamInput.java:121) ~[elasticsearch-7.6.2.jar:7.6.2]

I'd then add a note, just in case: the driver itself uses the REST API, so it's effectively a SQL/ODBC - REST gateway. If your app doesn't need to work with multiple sources/drivers, you could just connect to Elasticsearch'es [REST SQL API](https://www.elastic.co/guide/en/elasticsearch/reference/master/sql-rest.html) directly. Just FYI.

Finally, indeed, upgrading to a recent version is recommended (mind the [compat matrix](https://www.elastic.co/guide/en/elasticsearch/reference/master/sql-odbc-installation.html#odbc-compatibility)).

---

<div class="post-metadata">

### Author: ![onkark](https://avatars.discourse-cdn.com/v4/letter/o/bbce88/32.png) [@onkark](https://discuss.elastic.co/u/onkark)
#### Post date: [April 5, 2021, 12:23pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/6 "2021-04-05T12:23:11Z")

</div>

Solved the issue by upgrading the version to 7.12.0.

But it is taking more time to fetch the result (in Elasticsearch 7.12.0) after firing the query than the previous version (Elasticsearch 7.6.2) and also than other RDBMS. As elastic is known for its fast retrieving speed, here it is seen to be delayed one. Are there some internal settings I need to change to improve speed of firing query & fetching results ?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 6, 2021, 4:11pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/7 "2021-04-06T16:11:45Z")

</div>

Well. I know that it can take some time to "warm up" the indices but once you have sent some requests to the index, that should be fast enough.

If not, may be describe in another thread what you are doing and how slow it is. And also try to run the same query from Dev Tools using Kibana Dev Console using a pure elasticsearch "curl-a-like" query and see how fast it is.

---

<div class="post-metadata">

### Author: ![onkark](https://avatars.discourse-cdn.com/v4/letter/o/bbce88/32.png) [@onkark](https://discuss.elastic.co/u/onkark)
#### Post date: [April 7, 2021, 10:19am UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/8 "2021-04-07T10:19:18Z")

</div>

Thank you for helping..

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 5, 2021, 10:19am UTC](https://discuss.elastic.co/t/elasticsearch-sql-odbc-driver-error-of-all-shards-failed/268448/9 "2021-05-05T10:19:44Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
