Failed to execute queryconn closed

Hello, I am trying to execute bulk inserts and upserts with a batch size of 1000, I ran only one instance and after 45 minutes, I got the following error logs:

time=“2021-07-08T06:54:49Z” level=error msg=“Failed to execute queryEOF” pid=32110
time=“2021-07-08T06:54:49Z” level=error msg=“Failed to execute queryconn closed” pid=32110
time=“2021-07-08T06:54:49Z” level=error msg=“Failed to execute queryconn closed” pid=32110

Why am getting this error and how can I fix it?

Hi @may98ank ! Which version of CockroachDB are you using? In older versions, if the query is too large, it would cause the connection to close and return errors like this. I wonder if that might be what’s happening.

Hi @rafiss , I am using version: 20.2.8 of cockroach. If this is happening because of large queries, Is there any way to fix this other than using smaller batchsize?

If it is a large query issue, you can increase the max size using SET CLUSTER SETTING sql.conn.max_read_buffer_message_size = 'X MiB'; (it defaults to 16 MiB). Choosing a larger value means that the server can use more memory, so make sure the machine you are running on has enough memory.

Are you using a prepared statement to run the bulk insert? (If possible, could you share the code / script you are using to do this?) What is your use case for doing these bulk inserts? If you are trying to import data into the cluster, we recommend using the IMPORT command.