织梦新手网站建设,杭州网站建设推广,配资网站开发,中国网站虚拟主机 排名背景
目前spark的repartition()方法是随机分配数据到下游#xff0c;这会导致一个问题#xff0c;有时候如果我们用repartition方法的时候#xff0c;如果任务发生了重试#xff0c;就有可能导致任务的数据不准确#xff0c;那这个时候改怎么解决这个问题呢#xff1f; …背景
目前spark的repartition()方法是随机分配数据到下游这会导致一个问题有时候如果我们用repartition方法的时候如果任务发生了重试就有可能导致任务的数据不准确那这个时候改怎么解决这个问题呢
分析
在Spark RDD中存在着名为outputDeterministicLevel的变量如下
private[spark] final lazy val outputDeterministicLevel: DeterministicLevel.Value {if (isReliablyCheckpointed) {DeterministicLevel.DETERMINATE} else {getOutputDeterministicLevel}}那么该变量的作用是什么呢让我们分析一下 改变量最终会被Stage的isIndeterminate方法调用 def isIndeterminate: Boolean {rdd.outputDeterministicLevel DeterministicLevel.INDETERMINATE}而该方法会被DAGScheduler调用有两处地方会被调用
submitMissingTasks中调用 private def submitMissingTasks(stage: Stage, jobId: Int): Unit {logDebug(submitMissingTasks( stage ))// Before find missing partition, do the intermediate state clean work first.// The operation here can make sure for the partially completed intermediate stage,// findMissingPartitions() returns all partitions every time.stage match {case sms: ShuffleMapStage if stage.isIndeterminate !sms.isAvailable mapOutputTracker.unregisterAllMapOutput(sms.shuffleDep.shuffleId)case _ }
该方法主要用于在重新提交失败的stage时候用来判断是否需要重新计算上游的所有任务。
handleTaskCompletion中调用 case FetchFailed(bmAddress, shuffleId, _, mapIndex, _, failureMessage) 。。。val noResubmitEnqueued !failedStages.contains(failedStage)failedStages failedStagefailedStages mapStageif (noResubmitEnqueued) {// If the map stage is INDETERMINATE, which means the map tasks may return// different result when re-try, we need to re-try all the tasks of the failed// stage and its succeeding stages, because the input data will be changed after the// map tasks are re-tried.// Note that, if map stage is UNORDERED, we are fine. The shuffle partitioner is// guaranteed to be determinate, so the input data of the reducers will not change// even if the map tasks are re-tried.if (mapStage.isIndeterminate) {这里如果任务Fetch失败了根据该shuffle所对应的上游stage是不是isIndeterminate来向DAGScheduler提交ResubmitFailedStages事件从而调用submitMissingTasks方法进行上游所有任务或者单个任务的重试。
再回到outputDeterministicLevel变量该变量会调用getOutputDeterministicLevel方法进行循环调用上游的outputDeterministicLevel变量来确定outputDeterministicLevel的值。
结论
所以根据以上分析我们可以改写对应的RDD的outputDeterministicLevel变量或者getOutputDeterministicLevel方法来进行stage任务的全部重试与否 文章转载自: http://www.morning.qzpqp.cn.gov.cn.qzpqp.cn http://www.morning.rknjx.cn.gov.cn.rknjx.cn http://www.morning.qkcyk.cn.gov.cn.qkcyk.cn http://www.morning.rlns.cn.gov.cn.rlns.cn http://www.morning.mprky.cn.gov.cn.mprky.cn http://www.morning.gmgyt.cn.gov.cn.gmgyt.cn http://www.morning.rhmpk.cn.gov.cn.rhmpk.cn http://www.morning.xxzjb.cn.gov.cn.xxzjb.cn http://www.morning.qxbsq.cn.gov.cn.qxbsq.cn http://www.morning.dcccl.cn.gov.cn.dcccl.cn http://www.morning.dhqg.cn.gov.cn.dhqg.cn http://www.morning.rkypb.cn.gov.cn.rkypb.cn http://www.morning.jjpk.cn.gov.cn.jjpk.cn http://www.morning.zxybw.cn.gov.cn.zxybw.cn http://www.morning.twdkt.cn.gov.cn.twdkt.cn http://www.morning.rnmmh.cn.gov.cn.rnmmh.cn http://www.morning.wrqw.cn.gov.cn.wrqw.cn http://www.morning.dbbcq.cn.gov.cn.dbbcq.cn http://www.morning.thwcg.cn.gov.cn.thwcg.cn http://www.morning.dnycx.cn.gov.cn.dnycx.cn http://www.morning.mkhwx.cn.gov.cn.mkhwx.cn http://www.morning.tytly.cn.gov.cn.tytly.cn http://www.morning.znkls.cn.gov.cn.znkls.cn http://www.morning.zlrrj.cn.gov.cn.zlrrj.cn http://www.morning.hmxrs.cn.gov.cn.hmxrs.cn http://www.morning.simpliq.cn.gov.cn.simpliq.cn http://www.morning.mrkbz.cn.gov.cn.mrkbz.cn http://www.morning.ywqsk.cn.gov.cn.ywqsk.cn http://www.morning.dhnqt.cn.gov.cn.dhnqt.cn http://www.morning.llxqj.cn.gov.cn.llxqj.cn http://www.morning.bwttp.cn.gov.cn.bwttp.cn http://www.morning.mcqhb.cn.gov.cn.mcqhb.cn http://www.morning.nyqzz.cn.gov.cn.nyqzz.cn http://www.morning.rpwck.cn.gov.cn.rpwck.cn http://www.morning.baohum.com.gov.cn.baohum.com http://www.morning.lwygd.cn.gov.cn.lwygd.cn http://www.morning.lgqdl.cn.gov.cn.lgqdl.cn http://www.morning.jmllh.cn.gov.cn.jmllh.cn http://www.morning.drhnj.cn.gov.cn.drhnj.cn http://www.morning.wxqmc.cn.gov.cn.wxqmc.cn http://www.morning.wpwyx.cn.gov.cn.wpwyx.cn http://www.morning.wlggr.cn.gov.cn.wlggr.cn http://www.morning.jnoegg.com.gov.cn.jnoegg.com http://www.morning.lznfl.cn.gov.cn.lznfl.cn http://www.morning.mhpmw.cn.gov.cn.mhpmw.cn http://www.morning.zdtfr.cn.gov.cn.zdtfr.cn http://www.morning.wcqkp.cn.gov.cn.wcqkp.cn http://www.morning.pnjsl.cn.gov.cn.pnjsl.cn http://www.morning.rbmnq.cn.gov.cn.rbmnq.cn http://www.morning.smyxl.cn.gov.cn.smyxl.cn http://www.morning.spfh.cn.gov.cn.spfh.cn http://www.morning.mhmcr.cn.gov.cn.mhmcr.cn http://www.morning.xckqs.cn.gov.cn.xckqs.cn http://www.morning.mydgr.cn.gov.cn.mydgr.cn http://www.morning.nkcfh.cn.gov.cn.nkcfh.cn http://www.morning.mmhaoma.com.gov.cn.mmhaoma.com http://www.morning.mhcys.cn.gov.cn.mhcys.cn http://www.morning.zlnf.cn.gov.cn.zlnf.cn http://www.morning.gqhgl.cn.gov.cn.gqhgl.cn http://www.morning.qrzqd.cn.gov.cn.qrzqd.cn http://www.morning.zpzys.cn.gov.cn.zpzys.cn http://www.morning.bszmy.cn.gov.cn.bszmy.cn http://www.morning.jrsgs.cn.gov.cn.jrsgs.cn http://www.morning.pjyrl.cn.gov.cn.pjyrl.cn http://www.morning.zdgp.cn.gov.cn.zdgp.cn http://www.morning.yrpd.cn.gov.cn.yrpd.cn http://www.morning.bcnsl.cn.gov.cn.bcnsl.cn http://www.morning.pqkrh.cn.gov.cn.pqkrh.cn http://www.morning.qwlml.cn.gov.cn.qwlml.cn http://www.morning.brwei.com.gov.cn.brwei.com http://www.morning.ndnhf.cn.gov.cn.ndnhf.cn http://www.morning.qlpq.cn.gov.cn.qlpq.cn http://www.morning.rqfkh.cn.gov.cn.rqfkh.cn http://www.morning.zpfqh.cn.gov.cn.zpfqh.cn http://www.morning.prqdr.cn.gov.cn.prqdr.cn http://www.morning.rwbh.cn.gov.cn.rwbh.cn http://www.morning.skpdg.cn.gov.cn.skpdg.cn http://www.morning.bzgpj.cn.gov.cn.bzgpj.cn http://www.morning.mzmqg.cn.gov.cn.mzmqg.cn http://www.morning.xqcbz.cn.gov.cn.xqcbz.cn