I'm still trying to figure my way in Cassandra world and I managed to successfully import some legacy stuff from a MySQL to Cassandra in a 'legacy_imports' keyspace.
The problem is, my working version is in an other keyspace 'stats' and I'd like to keep 'legacy_imports' with me somewhere and merge it on 'stats' as well. So the wanted operation here is just to copy some tables (including COUNTER tables) from a keyspace to another on the same node.
I tried to COPY ... TO but I had an error :
<ErrorMessage code=0000 [Server error] message="com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: org.apache.cassandra.exceptions.ReadTimeoutException: Operation timed out - received only 1 responses.">
I also tried sstableloader but I had a hard time working with it. My data is split on 2 disks and paths looks like this :
/media/disk2/cassandra/data/legacy_imports/log_by_day-1e6b7de0a90111e49471715135b1c904/snapshots/1422680322490-log_by_day/legacy_imports-log_by_day-ka-1-Data.db
When I try sstableloader, in legacy_imports directory, I get :
Could not retrieve endpoint ranges:
InvalidRequestException(why:No such keyspace: snapshots)
And finally if I do it only on legacy_imports, I get :
Exception in thread "main" java.lang.NullPointerException
at org.apache.cassandra.io.sstable.SSTableLoader.<init>(SSTableLoader.java:71)
at org.apache.cassandra.tools.BulkLoader.main(BulkLoader.java:79)
The COPY command is unfortunately not very performant prior to C* 2.1 so it does run into issues occasionally. The particular error you are receiving is because one of the reads was being preformed but the result was not obtained within your timeout parameter. Note that it did say it received one response which means at least one node was able to respond in time. This means you may be ok with a lower consistency level.
I think the best (and scalable solution) is to use something like spark to do the transfer. Something like
sc.cassandraTable("firstKeyspace","legacy_table").saveToCassandra("secondKeyspace","otherTable")
Another solution is to write a short driver program to do this for you where your data is read from one table and written to the other. Here you can have a more finely adjusted write control so you can handle ReadTimeouts/WriteTimeouts or even transform data before re-writing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With