# Timeout during YCQL Batch Inserts

**URL:** <https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929>\
**Category:** General\
**Created:** [January 2, 2023, 8:14pm UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929 "2023-01-02T20:14:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ulim](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/ulim/32/593_2.png) [@ulim](https://forum.yugabyte.com/u/ulim)\
**Post date:** [January 2, 2023, 8:14pm UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/1 "2023-01-02T20:14:37Z")

</div>

Hi there,

I am getting this exception for a batch of 50000 inserts (single node cluster, local laptop):

com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S  
at com.datastax.oss.driver.api.core.DriverTimeoutException.copy(DriverTimeoutException.java:34) ~[java-driver-core-4.6.0-yb-11.jar

The timeout appears to be 2 seconds, because if I reduce my batch size to 40000, then I do not get this timeout and the running times I measure for each such batch is always slightly less than 2 seconds.

I have not configured any timeouts myself, so I suppose there is some default value - how can I change that? 2 seconds appears to be awfully little for data ingestion.

My Java code for batch inserting is:

```
    BatchStatementBuilder builder = new BatchStatementBuilder(BatchType.UNLOGGED);
    PreparedStatement stmt = createPreparedStatementForMyData(...);
    for (Map<String, Object> row : myRows) {
        Object[] values = createValuesForOneRow(...);
        builder.addStatement(stmt.bind(values));
    }
    session.execute(builder.build());

```

The total running time for data ingestion (if I reduce my batch size enough to avoid the timeout) appears to be pretty much on par with some other databases I tested. But one other thing that I find weird: when I login to the ycqlsh shell, then I will not see any new data being created while logged in - all I ever see is the data that has been present at login.

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [January 3, 2023, 7:58am UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/2 "2023-01-03T07:58:24Z")

</div>

@ulim

Does this help [https://support.yugabyte.com/hc/en-us/articles/4403707196557-Getting-error-messages-like-Timed-out-waiting-for-server-response-and-Client-request-timeout-](https://support.yugabyte.com/hc/en-us/articles/4403707196557-Getting-error-messages-like-Timed-out-waiting-for-server-response-and-Client-request-timeout-) ?

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [January 3, 2023, 8:02am UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/3 "2023-01-03T08:02:48Z")

</div>

> [@ulim](#):
>
> But one other thing that I find weird: when I login to the ycqlsh shell, then I will not see any new data being created while logged in - all I ever see is the data that has been present at login.

This is weird.

How are you verifying this?

And how can we reproduce it?

What do you mean by `while being logged in`? If you close and re-open ycqlsh it shows up?

YCQL transaction mode is “autocommit”, so there shouldn’t be any state between queries and new data should show up.

---

<div class="post-metadata">

**Author:** ![ulim](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/ulim/32/593_2.png) [@ulim](https://forum.yugabyte.com/u/ulim)\
**Post date:** [January 3, 2023, 10:38am UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/4 "2023-01-03T10:38:41Z")

</div>

I saw this article, but thought it didn’t apply to my case. I am seeing a timeout value of 2 seconds, not 10 or 60 as mentioned in this article. Also, in the article it is only explained how to set the timeout for cqlsh, but I need to set it for the Java driver. Also, if that matters, the client (my application) doesn’t read anything, it just INSERTs.

---

<div class="post-metadata">

**Author:** ![ulim](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/ulim/32/593_2.png) [@ulim](https://forum.yugabyte.com/u/ulim)\
**Post date:** [January 3, 2023, 10:44am UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/5 "2023-01-03T10:44:18Z")

</div>

About the cqlsh situation: I am starting cqlsh and do “describe tables;”. Then via my application I am creating new tables. My expectation would be that another “describe tables;” would then show the new tables and I could select from them. But in reality I have to restart cqlsh to see the new tables.

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [January 3, 2023, 11:43am UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/6 "2023-01-03T11:43:52Z")

</div>

Can replicate this with 2 ycqlsh clis opened. ycqlsh is probably caching the tables somehow. Can you create an issue on [github](https://github.com/yugabyte/yugabyte-db/issues)?

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [January 3, 2023, 2:08pm UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/7 "2023-01-03T14:08:46Z")

</div>

> [@ulim](#):
>
> I saw this article, but thought it didn’t apply to my case. I am seeing a timeout value of 2 seconds, not 10 or 60 as mentioned in this article. Also, in the article it is only explained how to set the timeout for cqlsh, but I need to set it for the Java driver. Also, if that matters, the client (my application) doesn’t read anything, it just INSERTs.

cc @nmalladi for answer on java driver

---

<div class="post-metadata">

**Author:** ![ulim](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/ulim/32/593_2.png) [@ulim](https://forum.yugabyte.com/u/ulim)\
**Post date:** [January 10, 2023, 11:11am UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/8 "2023-01-10T11:11:55Z")

</div>

Any updates on this? I am getting timeouts left and right, a lot of interesting stuff cannot be done inside 2 seconds.

---

<div class="post-metadata">

**Author:** ![FranckPachot](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/franckpachot/32/353_2.png) [@FranckPachot](https://forum.yugabyte.com/u/FranckPachot)\
**Post date:** [January 10, 2023, 11:44am UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/9 "2023-01-10T11:44:48Z")

</div>

> [@ulim](#):
>
> I have not configured any timeouts myself

Isn’t 2 seconds the default for write\_request\_timeout\_in\_ms ? Like here:

> **[The cassandra.yaml configuration file](https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/configuration/configCassandra_yaml.html#configCassandra_yaml__write_request_timeout_in_ms)**
>
> The cassandra.yaml file is the main configuration file for Cassandra.

---

<div class="post-metadata">

**Author:** ![ulim](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/ulim/32/593_2.png) [@ulim](https://forum.yugabyte.com/u/ulim)\
**Post date:** [January 10, 2023, 12:11pm UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/10 "2023-01-10T12:11:34Z")

</div>

Yes, possibly. The question was two-fold:

a) which timeout-related configuration values are available? I believe your link answers that, many thanks for that.  
b) how to set these values in the Java driver for Yugabyte?

---

<div class="post-metadata">

**Author:** ![ulim](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/ulim/32/593_2.png) [@ulim](https://forum.yugabyte.com/u/ulim)\
**Post date:** [January 11, 2023, 1:33pm UTC](https://forum.yugabyte.com/t/timeout-during-ycql-batch-inserts/1929/11 "2023-01-11T13:33:40Z")

</div>

Ok, I got this. There needs to be a file “application.conf” in the classpath and it should contain something like this:

```auto
datastax-java-driver {
  profiles {
    MY_PROFILE {
      basic.request.timeout = 25 seconds
    }
  }
}

```

Then later in the Java code this can be activated by:

```auto
SimpleStatement stmt = SimpleStatement.newInstance("select * from ...");
session.execute(stmt.setExecutionProfileName("MY_PROFILE"));

```
