-
Notifications
You must be signed in to change notification settings - Fork 918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPARKC-503: Retry PoolBusy Exceptions, Throttle JWCT Calls #1137
Conversation
A change in the Cassandra Java driver has caused the executeAsync method to become fully asynchronous. This means that executeAsync calls can sometimes return an exception of BusyPoolException, meaning that queries were issued and no open execution pathway could be found. These exceptions are always retryable because they indicate the local driver state is temporarly busy. So we will retry these exceptions. To make sure we don't have too many retries we will also make sure to limit the number of max concurrent requests to the current "requestsPerConnection" as specified in the pooling options. We are already setting the maxPool size to the number of cores per executor so this should prohibit having more requests in flight than we have open connections.
Build against Scala 2.11 finished with failure |
Build against Scala 2.10 finished with success |
Build against Scala 2.11 finished with success |
@@ -194,6 +194,15 @@ class TableWriterSpec extends SparkCassandraITFlatSpecBase { | |||
verifyKeyValueTable("key_value") | |||
} | |||
|
|||
it should "pass the exception back to the driver on a write failure" in { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
travis does not like this test https://travis-ci.org/datastax/spark-cassandra-connector/jobs/264511105#L4452
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -18,6 +19,7 @@ class AsyncExecutor[T, R](asyncAction: T => ListenableFuture[R], maxConcurrentTa | |||
|
|||
private val semaphore = new Semaphore(maxConcurrentTasks) | |||
private val pendingFutures = new TrieMap[ListenableFuture[R], Boolean] | |||
var latestExeception: Option[Throwable] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make this private and expose exc info as read only thing?
if (_successful) _successful = false | ||
release() | ||
settable.setException(throwable) | ||
latestExeception = Some(throwable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since _successful
volatile write is conditional, we could make _successful not volatile and make latestException volatile. This may make Travis happy :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it looks like it should be placed in critical section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure what you mean in "the critical section"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm meant putting it before release()
, it's all good now
throw new IOException( | ||
s"""Failed to write statements to $keyspaceName.$tableName. The | ||
|latest exception was | ||
| ${queryExecutor.latestExeception.map( _.getMessage).getOrElse("Unable to determine")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like _successful
(and successful
) is redundant. The if could be changed to latestException.map(...)
@RussellSpitzer could you also elaborate a bit about
If I understand correctly, max concurrent requests while saving to C* is limited by |
Build against Scala 2.10 finished with failure |
@jtgrabowski MaxConcurrentRequests is set only for the apply method of the query executor. The Write method is still throttled as before based on "max_concurrent_writes" I didn't want to add a new tuning parameter in a point release and the driver team told me this should be safe :) |
retest this please |
Build against Scala 2.10 finished with failure |
1 similar comment
Build against Scala 2.10 finished with failure |
Build against Scala 2.11 finished with failure |
Build against Scala 2.11 finished with success |
5ec5f7b
to
cd14ff2
Compare
Build against Scala 2.10 finished with success |
Build against Scala 2.11 finished with success |
private val semaphore = new Semaphore(maxConcurrentTasks) | ||
private val pendingFutures = new TrieMap[ListenableFuture[R], Boolean] | ||
@volatile private var latestException: Option[Throwable] = None | ||
|
||
def getLatestException(): Option[Throwable] = synchronized { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we synchronize here?
LGTM but please take a look at |
cd14ff2
to
7ec48b3
Compare
Build against Scala 2.10 finished with success |
Build against Scala 2.11 finished with success |
A change in the Cassandra Java driver has caused the executeAsync method
to become fully asynchronous. This means that executeAsync calls can
sometimes return an exception of BusyPoolException, meaning that queries
were issued and no open execution pathway could be found. These
exceptions are always retryable because they indicate the local driver
state is temporarly busy. So we will retry these exceptions.
To make sure we don't have too many retries we will also make sure to
limit the number of max concurrent requests to the current
"requestsPerConnection" as specified in the pooling options. We are
already setting the maxPool size to the number of cores per executor so
this should prohibit having more requests in flight than we have open
connections.