Skip to content
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

Merged
merged 2 commits into from
Aug 17, 2017

Conversation

RussellSpitzer
Copy link
Contributor

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.

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.
@ds-jenkins-builds
Copy link

Build against Scala 2.11 finished with failure

@ds-jenkins-builds
Copy link

Build against Scala 2.10 finished with success

@ds-jenkins-builds
Copy link

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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
Copy link
Collaborator

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)
Copy link
Collaborator

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 :)

Copy link
Collaborator

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.

Copy link
Contributor Author

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"

Copy link
Collaborator

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")}
Copy link
Collaborator

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(...)

@jtgrabowski
Copy link
Collaborator

@RussellSpitzer could you also elaborate a bit about

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

If I understand correctly, max concurrent requests while saving to C* is limited by spark.cassandra.output.concurrent.writes and in case of joining, it is bound to whatever is found in poolingOptions.getMaxRequestsPerConnection. This is not configurable (unless custom ConnectionFactory is provided). Is this intended?

@ds-jenkins-builds
Copy link

Build against Scala 2.10 finished with failure

@RussellSpitzer
Copy link
Contributor Author

@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 :)

@RussellSpitzer
Copy link
Contributor Author

retest this please

@ds-jenkins-builds
Copy link

Build against Scala 2.10 finished with failure

1 similar comment
@ds-jenkins-builds
Copy link

Build against Scala 2.10 finished with failure

@ds-jenkins-builds
Copy link

Build against Scala 2.11 finished with failure

@ds-jenkins-builds
Copy link

Build against Scala 2.11 finished with success

@ds-jenkins-builds
Copy link

Build against Scala 2.10 finished with success

@ds-jenkins-builds
Copy link

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 {
Copy link
Collaborator

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?

@jtgrabowski
Copy link
Collaborator

LGTM but please take a look at synchronized and see if we need it

@ds-jenkins-builds
Copy link

Build against Scala 2.10 finished with success

@ds-jenkins-builds
Copy link

Build against Scala 2.11 finished with success

@RussellSpitzer RussellSpitzer merged commit 072a43d into b2.0 Aug 17, 2017
@RussellSpitzer RussellSpitzer deleted the SPARKC-503 branch March 27, 2020 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants