Joshua Davies
Joshua Davies

Reputation: 1081

cqlsh -e "copy table" hangs forever

I have a handful of tables that I want to copy from one Cassandra cluster to another; I figured the most straightforward way to do this would be to run a series of shell commands like:

cqlsh -e "copy keyspace.table1 to 'table1.csv' with header = true;

(and then a series of inverse shell commands to copy into the new cluster).

However, when I run this, I see:

Using 11 child processes

Starting copy of keyspace.table1 with columns [column1, column2, column3, column4].

But the process hangs forever, never adding to the target CSV file.

Upvotes: 3

Views: 503

Answers (2)

user1401472
user1401472

Reputation: 2301

What is # of rows and size of each row in the table you are trying to copy? Its not optimal to use COPY if both size of a row and # of rows are huge.

One option you can try out is to reduce batch size.

cqlsh -e "copy table keyspace.table1 to 'table1.csv' with header = true AND MAXBATCHSIZE=5;

This may take longer, but it will surely end. I have had similar issue with a table having close to 30M records and reducing batch size helped.

Upvotes: 1

Carlos Monroy Nieblas
Carlos Monroy Nieblas

Reputation: 2283

It may be more efficient to use take a snapshot of the table with

nodetool snapshot -cf <table_name> -t <snpashot_id> <keyspace>

where keyspace and table name are the names of your structure; snapshot_id will be a label that will help you to identify the snapshot.

You will be abele to verify the snapshot with nodetool listsnapshots, then restore it with the procedure explained here.

Once that you are done with the procedure, you'll need to do some house cleaning with nodetool clearsnapshot <snapshot_id>

Upvotes: 0

Related Questions