TiSpark的jar包是tispark-assembly-3.1_2.12-3.3.0.jar
Spark版本3.1.1
通过datasource api写入表,代码如下:
df.write().format("tidb")
.option("database", database)
.option("table", table)
.option("replace", "true")
.mode("append")
.save();
对于有些表,写入没有问题,但有的表写入会报错:
org.tikv.common.exception.TiBatchWriteException: Execution exception met.
at org.tikv.txn.TwoPhaseCommitter.doPrewriteSecondaryKeys(TwoPhaseCommitter.java:308)
at org.tikv.txn.TwoPhaseCommitter.prewriteSecondaryKeys(TwoPhaseCommitter.java:259)
at com.pingcap.tispark.utils.TwoPhaseCommitHepler.$anonfun$prewriteSecondaryKeyByExecutors$1(TwoPhaseCommitHepler.scala:102)
at com.pingcap.tispark.utils.TwoPhaseCommitHepler.$anonfun$prewriteSecondaryKeyByExecutors$1$adapted(TwoPhaseCommitHepler.scala:90)
at org.apache.spark.rdd.RDD.$anonfun$foreachPartition$2(RDD.scala:1020)
at org.apache.spark.rdd.RDD.$anonfun$foreachPartition$2$adapted(RDD.scala:1020)
at org.apache.spark.SparkContext.$anonfun$runJob$5(SparkContext.scala:2242)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
at org.apache.spark.scheduler.Task.run(Task.scala:131)
at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:497)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1439)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:500)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.util.concurrent.ExecutionException: org.tikv.common.exception.TiBatchWriteException: prewrite secondary key error
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.tikv.txn.TwoPhaseCommitter.doPrewriteSecondaryKeys(TwoPhaseCommitter.java:285)
... 14 more
Caused by: org.tikv.common.exception.TiBatchWriteException: prewrite secondary key error
at org.tikv.txn.TwoPhaseCommitter.doPrewriteSecondaryKeySingleBatchWithRetry(TwoPhaseCommitter.java:426)
at org.tikv.txn.TwoPhaseCommitter.doPrewriteSecondaryKeysInBatchesWithRetry(TwoPhaseCommitter.java:357)
at org.tikv.txn.TwoPhaseCommitter.retryPrewriteBatch(TwoPhaseCommitter.java:390)
at org.tikv.txn.TwoPhaseCommitter.doPrewriteSecondaryKeySingleBatchWithRetry(TwoPhaseCommitter.java:439)
at org.tikv.txn.TwoPhaseCommitter.doPrewriteSecondaryKeysInBatchesWithRetry(TwoPhaseCommitter.java:357)
at org.tikv.txn.TwoPhaseCommitter.lambda$doPrewriteSecondaryKeys$0(TwoPhaseCommitter.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
... 3 more
Caused by: org.tikv.common.exception.GrpcException: org.tikv.shade.io.grpc.StatusRuntimeException: UNIMPLEMENTED
at org.tikv.common.policy.RetryPolicy.rethrowNotRecoverableException(RetryPolicy.java:70)
at org.tikv.common.policy.RetryPolicy.callWithRetry(RetryPolicy.java:94)
at org.tikv.common.AbstractGRPCClient.callWithRetry(AbstractGRPCClient.java:88)
at org.tikv.common.region.RegionStoreClient.prewrite(RegionStoreClient.java:486)
at org.tikv.common.region.RegionStoreClient.prewrite(RegionStoreClient.java:435)
at org.tikv.txn.TxnKVClient.prewrite(TxnKVClient.java:104)
at org.tikv.txn.TwoPhaseCommitter.doPrewriteSecondaryKeySingleBatchWithRetry(TwoPhaseCommitter.java:416)
... 11 more
Caused by: org.tikv.shade.io.grpc.StatusRuntimeException: UNIMPLEMENTED
at org.tikv.shade.io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:287)
at org.tikv.shade.io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:268)
at org.tikv.shade.io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:175)
at org.tikv.common.AbstractGRPCClient.lambda$callWithRetry$0(AbstractGRPCClient.java:91)
at org.tikv.common.policy.RetryPolicy.callWithRetry(RetryPolicy.java:88)
... 16 more
请问该如何排查问题