TiSpark 程序运行中报错 Unavailable desc = not leader

之前跑的数据是 10万,报的下面第一个错,不过数据跑出来了。这次跑的是 100万,两个错都有报,程序跑了1个小时直接退出了。

程序如下:

val sparkConf = new SparkConf()
      .set("spark.app.name", "Tidb Test")
      .setIfMissing("spark.tispark.write.allow_spark_sql", "true")
      .setIfMissing("spark.master", "local[4]")
      .setIfMissing("spark.sql.extensions", "org.apache.spark.sql.TiExtensions")
      .setIfMissing("spark.tispark.tidb.addr", "172.16.1.130")
      .setIfMissing("spark.tispark.tidb.password", "example")
      .setIfMissing("spark.tispark.tidb.port", "3390")
      .setIfMissing("spark.tispark.tidb.user", "root")
      .setIfMissing("spark.tispark.write.without_lock_table", "true")
      .setIfMissing("writeConcurrency", "24")
      .setIfMissing("spark.tispark.pd.addresses", "http://172.16.1.131:2379,http://172.16.1.132:2379,http://172.16.1.134:2379")
    SparkSession.builder.config(sparkConf).getOrCreate()

...

def writeTarget(sqlContext: SQLContext): Unit = {
    val df = sqlContext.read
      .format("tidb")
      .option("database", "law")
      .option("table", "cases")
      .load()
    df.limit(1000000)
      .write
      .format("tidb")
      .option("database", "test")
      .option("table", "target_cases")
      .option("regionSplitNum", 20)
      .option("writeConcurrency", 24)
      .option("delay-clean-table-lock", 60000)
      .mode("append")
      .save()
  }

前期报错:

UNKNOWN: rpc error: code = Unavailable desc = not leader

后期报错:

com.pingcap.tikv.exception.KeyException: tikv restart txn Txn(Mvcc(TxnLockNotFound { start_ts: 411772526951137286, commit_ts: 411773218940780545, key: [116, 128, 0, 0, 0, 0, 0, 0, 102, 95, 105, 128, 0, 0, 0, 0, 0, 0, 1, 1, 98, 48, 48, 48, 56, 56, 54, 56, 255, 54, 49, 54, 55, 0, 0, 0, 0, 251] }))

完整的运行日志:https://paste.ubuntu.com/p/sRrfzFcwQn/

(Mvcc(TxnLockNotFound 这个报错应该是跟你运行时间过长,数据被 GC 掉了。

程序跑了一个小时的时间。如果是运行时间过长的话,那么如何解决呢?

你这个报错是什么时候报出来的,tikv-gc-life-time max-txn-time-use max-execution-time 看一下这几个参数分别是多少把。

大概是在程序启动后第42分钟开始报的错。
具体的参数,用的是默认配置。其中 tikv-gc-life-time 是10m0s,max-txn-time-use 590秒 ,max_execution_time 为 0

你试一下如果 将tikv-gc-life-time 改到一个很大的值还会不会报错。

还是大概100万条数据。现在报这个错。rpc error: code = Unavailable desc = not leader,然后发生异常:GrpcException: retry is exhausted. 就结束了。这是什么原因?

完整日志:https://paste.ubuntu.com/p/YCMCmjZfSy/

1 个赞

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。