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

Fix concurrent dagrequest issue #714

Merged
merged 4 commits into from May 15, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -180,6 +180,7 @@ case class RegionTaskExec(child: SparkPlan,
private val downgradeThreshold =
sqlConf.getConfString(TiConfigConst.REGION_INDEX_SCAN_DOWNGRADE_THRESHOLD, "10000").toInt
private lazy val project = UnsafeProjection.create(schema)
private val logger = Logger.getLogger(getClass.getName)
birdstorm marked this conversation as resolved.
Show resolved Hide resolved

type TiRow = com.pingcap.tikv.row.Row

Expand Down Expand Up @@ -215,7 +216,6 @@ case class RegionTaskExec(child: SparkPlan,
downgradeDagRequest: TiDAGRequest
): (Int, Iterator[InternalRow]) => Iterator[UnsafeRow] = { (index, iter) =>
// For each partition, we do some initialization work
val logger = Logger.getLogger(getClass.getName)
logger.debug(s"In partition No.$index")
val session = TiSessionCache.getSession(tiConf)
session.injectCallBackFunc(callBackFunc)
Expand Down Expand Up @@ -261,7 +261,7 @@ case class RegionTaskExec(child: SparkPlan,
taskCount += 1
val task = new Callable[util.Iterator[TiRow]] {
override def call(): util.Iterator[TiRow] =
CoprocessIterator.getRowIterator(dagRequest.copy(), tasks, session)
CoprocessIterator.getRowIterator(dagRequest, tasks, session)
}
completionService.submit(task)
}
Expand Down
Expand Up @@ -19,11 +19,9 @@ package org.apache.spark.sql.test

import java.io.File
import java.sql.{Connection, DriverManager, Statement}
import java.util
import java.util.{Locale, Properties, TimeZone}

import com.pingcap.tispark.TiConfigConst.PD_ADDRESSES
import com.pingcap.tispark.TiDBOptions
import com.pingcap.tispark.statistics.StatisticsManager
import org.apache.spark.internal.Logging
import org.apache.spark.sql._
Expand Down
Expand Up @@ -43,7 +43,7 @@ public static SchemaInfer create(TiDAGRequest dagRequest) {
}

public static SchemaInfer create(TiDAGRequest dagRequest, boolean readHandle) {
return new SchemaInfer(dagRequest, readHandle);
return new SchemaInfer(dagRequest.copy(), readHandle);
}

private SchemaInfer(TiDAGRequest dagRequest, boolean readHandle) {
Expand Down
Expand Up @@ -71,12 +71,13 @@ public abstract class CoprocessIterator<T> implements Iterator<T> {
*/
public static CoprocessIterator<Row> getRowIterator(
TiDAGRequest req, List<RegionTask> regionTasks, TiSession session) {
TiDAGRequest dagRequest = req.copy();
return new DAGIterator<Row>(
req.buildTableScan(),
dagRequest.buildTableScan(),
regionTasks,
session,
SchemaInfer.create(req),
req.getPushDownType()) {
SchemaInfer.create(dagRequest),
dagRequest.getPushDownType()) {
@Override
public Row next() {
if (hasNext()) {
Expand Down