|
| 1 | +# Documentation |
| 2 | + |
| 3 | +## Frequently Asked Questions |
| 4 | + |
| 5 | +### Why is my job running on a single executor? Why am I not seeing any parallelism? |
| 6 | + |
| 7 | +The first thing to check when you see that a Spark job is not being parallelized is to |
| 8 | +determine how many tasks have been generated. To check this look at the UI for your spark |
| 9 | +job and see how many tasks are being run. In the current Shell a small progress bar is shown |
| 10 | +when running stages, the numbers represent (Completed Tasks + Running Tasks) / Total Tasks |
| 11 | + |
| 12 | + [Stage 2:=============================================> (121 + 1) / 200]0 |
| 13 | + |
| 14 | +If you see that only a single task has been created this means that the Cassandra Token range has |
| 15 | +not been split into a enough tasks to be well parallelized on your cluster. The number of |
| 16 | +Spark partitions(tasks) created is directly controlled by the setting `spark.cassandra.input.split.size`. |
| 17 | +This number reflects the approximate number of live Cassandra Partitions in a given Spark partition. |
| 18 | +To increase the number of Spark Partitions decrease this number from the default (100k) to one that |
| 19 | +will sufficiently break up your C* token range. This can also be adjusted on a per cassandraTable basis |
| 20 | +with the function `withReadConf` and specifying a new `ReadConf` object. |
| 21 | + |
| 22 | +If there is more than one task but only a single machine is working, make sure that the job itself |
| 23 | +has been allocated multiple executor slots to work with. This is set at the time of SparkContext |
| 24 | +creation with `spark.cores.max` in the `SparkConf` and cannot be changed during the job. |
| 25 | + |
| 26 | +One last thing to check is whether there is a `where` clause with a partition-key predicate. Currently |
| 27 | +the Spark Cassandra Connector creates Spark Tasks which contain entire C* partitions. This method |
| 28 | +ensures a single C* partition request will always create a single Spark task. `where` clauses with |
| 29 | +an `in` will also generate a single Spark Partition. |
| 30 | + |
| 31 | +### Why can't the spark job find Spark Cassandra Connector Classes? (ClassNotFound Exceptions for SCC Classes) |
| 32 | + |
| 33 | +The most common cause for this is that the executor classpath does not contain the Spark Cassandra Connector |
| 34 | +jars. The simplest way to add these to the class path is to use SparkSubmit with the --jars option pointing |
| 35 | +to your Spark Cassandra Connector assembly jar. If this is impossible, the second best option |
| 36 | +is to manually distribute the jar to all of your executors and add the jar's location to `spark.executor.extraClassPath` |
| 37 | +in the SparkConf or spark-defaults.conf. |
| 38 | + |
| 39 | +### Where should I set configuration options for the connector? |
| 40 | + |
| 41 | +The suggested location is to use the `spark-defaults.conf` file in your spark/conf directory but |
| 42 | +this file is ONLY used by spark-submit. Any applications not running through spark submit will ignore |
| 43 | +this file. You can also specify Spark-Submit conf options with `--conf option=value` on the command |
| 44 | +line. |
| 45 | + |
| 46 | +For applications not running through spark submit, set the options in the `SparkConf` object used to |
| 47 | +create your `SparkContext`. Usually this will take the form of a series of statements that look like |
| 48 | + |
| 49 | +```scala |
| 50 | +val conf = SparkConf() |
| 51 | + .set("Option","Value") |
| 52 | + ... |
| 53 | + |
| 54 | +val sc = SparkContext(conf) |
| 55 | +``` |
| 56 | + |
| 57 | +### Why are my write tasks timing out/ failing? |
| 58 | + |
| 59 | +The most common cause of this is that Spark is able to issue write requests much more quickly than |
| 60 | +Cassandra can handle them. This can lead to GC issues and build up of hints. If this is the case |
| 61 | +with your application, try lowering the number of concurrent writes and the current batch size using |
| 62 | +the following options. |
| 63 | + |
| 64 | + spark.cassandra.output.batch.size.rows |
| 65 | + spark.cassandra.output.concurrent.writes |
| 66 | + |
| 67 | +or in versions of the Spark Cassandra Connector greater than or equal to 1.2.0 set |
| 68 | + |
| 69 | + spark.cassandra.output.throughput_mb_per_sec |
| 70 | + |
| 71 | +which will allow you to control the amount of data written to C* per Spark core per second. |
| 72 | + |
| 73 | +### Why are my executors throwing `OutOfMemoryException`s while Reading from Cassandra? |
| 74 | + |
| 75 | +This usually means that the size of the partitions you are attempting to create are larger than |
| 76 | +the executor's heap can handle. Remember that all of the executors run in the same JVM so the size |
| 77 | +of the data is multiplied by the number of executor slots. |
| 78 | + |
| 79 | +To fix this either increase the heap size of the executors `spark.executor.memory` |
| 80 | + or shrink the size of the partitions by decreasing `spark.cassandra.input.split.size` |
| 81 | + |
| 82 | +### Why can't my spark job find My Application Classes / Anonymous Functions? |
| 83 | + |
| 84 | +This occurs when your application code hasn't been placed on the classpath of the Spark Executor. When using |
| 85 | +Spark Submit make sure that the jar contains all of the classes and dependencies for running your code. |
| 86 | +To build a fat jar look into using sbt assembly, or look for instructions for your build tool of choice. |
| 87 | + |
| 88 | +If you are not using the recommended approach with Spark Submit, make sure that your dependencies |
| 89 | +have been set in the `SparkConf` using `setJars` or by distributing the jars yourself and modifying |
| 90 | +the executor classpath. |
| 91 | + |
| 92 | +### Why don't my case classes work? |
| 93 | +Usually this is because they have been defined within another object/class. Try moving the definition |
| 94 | +outside of the scope of other classes. |
| 95 | + |
| 96 | +### Why can't my spark job connect to Cassandra? |
| 97 | + |
| 98 | +Check that your Cassandra instance is on and responds to cqlsh. Make sure that the rpc address also |
| 99 | +accepts incoming connections on the interface you are setting as `rpc_address` in the cassandra.yaml file. |
| 100 | +Make sure that you are setting the `spark.cassandra.connection.host` property to the interface which |
| 101 | +the rpc_address is set to. |
| 102 | + |
| 103 | +When troubleshooting Cassandra connections it is sometimes useful to set the rpc_address in the |
| 104 | +C* yaml file to `0.0.0.0` so any incoming connection will work. |
| 105 | + |
| 106 | + |
| 107 | +### Can I contribute to the Spark Cassandra Connector? |
| 108 | + |
| 109 | +YES! Feel free to start a Jira and detail the changes you would like to make or the feature you |
| 110 | +would like to add. We would be happy to discuss it with you and see your work. Feel free to create |
| 111 | + a Jira before you have started any work if you would like feedback on an idea. When you have a branch |
| 112 | +that you are satisfied with and passes all the tests (`/dev/run_tests.sh`) make a GitHub PR against |
| 113 | +your target Connector Version and set your Jira to Reviewing. |
| 114 | + |
| 115 | +### What should I do if I find a bug? |
| 116 | + |
| 117 | +Feel free to post a repo on the Mailing List or if you are feeling ambitious file a Jira with |
| 118 | +steps for reproduction and we'll get to it as soon as possible. Please remember to include a full |
| 119 | +stack trace (if any) and the versions of Spark, The Connector, and Cassandra that you are using. |
0 commit comments