Skip to content

Conversation

@AngersZhuuuu
Copy link
Contributor

@AngersZhuuuu AngersZhuuuu commented Mar 23, 2020

What changes were proposed in this pull request?

When last partition's splitFile's split size is larger then maxSize, this partition will be lost

Origin logic error like below as 1, 2, 3, 4, 5

// 5. since index = partition.size now,  jump out of the loop , then the last partition is lost since we won't call updatePartition() again.
while (index < partitions.size) {
     //  1. we assume that when index = partitions.length -1(the last partition) 
      val partition = partitions(index)
      val fileSplit =
        partition.asInstanceOf[HadoopPartition].inputSplit.value.asInstanceOf[FileSplit]
      val splitSize = fileSplit.getLength
     // 2.  if  this partition's  splitSize > maxSize
      if (currentSum + splitSize < maxSize) {
        addPartition(partition, splitSize)
        index += 1
        if (index == partitions.size) {
          updateGroups
        }
      } else {
       //  3. if currentGroup.partitions.size  >0, this situation is possiable
        if (currentGroup.partitions.size == 0) {
          addPartition(partition, splitSize)
          index += 1
        } else {
        //   4. then will just call updateGroups() here first, and index won't update in group
          updateGroups
        }
      }
    }
    groups.toArray
  }
}

Why are the changes needed?

Fix bug

Does this PR introduce any user-facing change?

NO

How was this patch tested?

Manual code review.

@dongjoon-hyun
Copy link
Member

ok to test

@dongjoon-hyun
Copy link
Member

Sorry for late visiting here, @AngersZhuuuu .
BTW, please use PR description instead of comment (#27988 (comment)).

  • The PR description will be a commit log with your patch.
  • A comment on PR is hard to find later.

@SparkQA
Copy link

SparkQA commented Apr 1, 2020

Test build #120689 has finished for PR 27988 at commit 2c4ef14.

  • This patch fails build dependency tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

index += 1
if (index == partitions.length) {
updateGroups()
}
Copy link
Member

Choose a reason for hiding this comment

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

BTW, the previous code was added at 2.0.0. Did you hit a test flakiness due to this?

Copy link
Contributor Author

@AngersZhuuuu AngersZhuuuu Apr 2, 2020

Choose a reason for hiding this comment

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

BTW, the previous code was added at 2.0.0. Did you hit a test flakiness due to this?

Yeah, these days I am testing a way to fix spark small out put file problem, and I use this logic, during test, found that this logic is wrong.
#27248

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-31226][SQL][TEST] SizeBasedCoalesce logic will lose partition [SPARK-31226][CORE][TEST] SizeBasedCoalesce logic will lose partition Apr 1, 2020
@dongjoon-hyun
Copy link
Member

Retest this please.

@SparkQA
Copy link

SparkQA commented Apr 1, 2020

Test build #120690 has finished for PR 27988 at commit 2c4ef14.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@AngersZhuuuu
Copy link
Contributor Author

Sorry for late visiting here, @AngersZhuuuu .
BTW, please use PR description instead of comment (#27988 (comment)).

  • The PR description will be a commit log with your patch.
  • A comment on PR is hard to find later.

Changed

@AngersZhuuuu
Copy link
Contributor Author

@dongjoon-hyun Any more need to add for this?

addPartition(partition, splitSize)
index += 1
} else {
updateGroups
Copy link
Contributor

Choose a reason for hiding this comment

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

can you point out which line/lines cause the bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you point out which line/lines cause the bug?

In the pr description I have show the case this bug happen. Not one line or some lines cause this error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you point out which line/lines cause the bug?

Change the desc make it more clear.

}
index += 1
if (index == partitions.length) {
updateGroups()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we do this after the loop exit? There is no early stop in this loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: can we do this after the loop exit? There is no early stop in this loop.

Sure, updated, since before exit loop, the last action is addPartition so currentGourps if not empty, we don't need to check if currentGroup is empty, just updateGroups

@SparkQA
Copy link

SparkQA commented Jul 10, 2020

Test build #125580 has finished for PR 27988 at commit d7764ac.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Jul 10, 2020

Test build #125615 has finished for PR 27988 at commit d7764ac.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@AngersZhuuuu
Copy link
Contributor Author

@cloud-fan The test failed is not related since only test RDDSuite.custom RDD coalescer will use this SizeBasedCoalescer

@AngersZhuuuu
Copy link
Contributor Author

retest this please

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-31226][CORE][TEST] SizeBasedCoalesce logic will lose partition [SPARK-31226][CORE][TESTS] SizeBasedCoalesce logic will lose partition Jul 10, 2020
updateGroups
updateGroups()
addPartition(partition, splitSize)
}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of the following,

if (currentGroup.partitions.isEmpty) {
  addPartition(partition, splitSize)
} else {
  updateGroups()
  addPartition(partition, splitSize)
}

The following will be better.

if (currentGroup.partitions.nonEmpty) {
  updateGroups()
}
addPartition(partition, splitSize)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thanks

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM (except one minor refactoring comment)

@SparkQA
Copy link

SparkQA commented Jul 11, 2020

Test build #125650 has finished for PR 27988 at commit d7764ac.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 11, 2020

Test build #125653 has finished for PR 27988 at commit 20b1183.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@AngersZhuuuu
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Jul 11, 2020

Test build #125665 has finished for PR 27988 at commit 20b1183.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member

maropu commented Jul 11, 2020

retest this please

@SparkQA
Copy link

SparkQA commented Jul 11, 2020

Test build #125670 has finished for PR 27988 at commit 20b1183.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM. Merged to master. Thanks, @AngersZhuuuu .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants