Skip to content

Conversation

@dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Mar 8, 2021

What changes were proposed in this pull request?

This PR aims to remove ParVector usage with withExistingConf in CastSuite in order to fix UT failures.

  • This was added by SPARK-33498 .
  • master branch doesn't use ParVector.
- new ParVector(ALL_TIMEZONES.toVector).foreach { zid =>
+ ALL_TIMEZONES.foreach { zid =>

Why are the changes needed?

withExistingConf is not thread-safe like the following. We should not use ParVector on it.

def withExistingConf[T](conf: SQLConf)(f: => T): T = {
  val old = existingConf.get()
  existingConf.set(conf)
  try {
    f
  } finally {
    if (old != null) {
      existingConf.set(old)
    } else {
      existingConf.remove()
    }
  }
}

Does this PR introduce any user-facing change?

BEFORE

$ build/sbt "catalyst/testOnly *AnsiCastSuiteWithAnsiModeOn *ExpressionEncoderSuite -- -z parse -z nested"
...
[info] *** 4 TESTS FAILED ***
[error] Failed: Total 8, Failed 4, Errors 0, Passed 4
[error] Failed tests:
[error] 	org.apache.spark.sql.catalyst.encoders.ExpressionEncoderSuite

AFTER

$ build/sbt "catalyst/testOnly *AnsiCastSuiteWithAnsiModeOn *ExpressionEncoderSuite -- -z parse -z nested"
...
[info] All tests passed.

How was this patch tested?

Pass the CIs on branch-3.1. Currently, it's broken.

@github-actions github-actions bot added the SQL label Mar 8, 2021
@dongjoon-hyun
Copy link
Member Author

cc @leanken , @cloud-fan , @rednaxelafx , @maropu , @kiszk , @viirya

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-34660][TESTS] Don't use ParVector with withExistingConf which is not thread-safe [SPARK-34660][TESTS][3.1] Don't use ParVector with withExistingConf which is not thread-safe Mar 8, 2021
@kiszk
Copy link
Member

kiszk commented Mar 8, 2021

Great analysis!

@dongjoon-hyun
Copy link
Member Author

Thank you, @kiszk !

@dongjoon-hyun
Copy link
Member Author

This is a test-only PR and I tested this manually. Merged to branch-3.1 to recover the branch.

dongjoon-hyun added a commit that referenced this pull request Mar 8, 2021
… which is not thread-safe

### What changes were proposed in this pull request?

This PR aims to remove `ParVector` usage with `withExistingConf` in `CastSuite` in order to fix UT failures.
- This was added by SPARK-33498 .
- `master` branch doesn't use `ParVector`.

```scala
- new ParVector(ALL_TIMEZONES.toVector).foreach { zid =>
+ ALL_TIMEZONES.foreach { zid =>
```

### Why are the changes needed?

`withExistingConf` is not thread-safe like the following. We should not use `ParVector` on it.
```scala
def withExistingConf[T](conf: SQLConf)(f: => T): T = {
  val old = existingConf.get()
  existingConf.set(conf)
  try {
    f
  } finally {
    if (old != null) {
      existingConf.set(old)
    } else {
      existingConf.remove()
    }
  }
}
```

### Does this PR introduce _any_ user-facing change?

**BEFORE**
```
$ build/sbt "catalyst/testOnly *AnsiCastSuiteWithAnsiModeOn *ExpressionEncoderSuite -- -z parse -z nested"
...
[info] *** 4 TESTS FAILED ***
[error] Failed: Total 8, Failed 4, Errors 0, Passed 4
[error] Failed tests:
[error] 	org.apache.spark.sql.catalyst.encoders.ExpressionEncoderSuite
```

**AFTER**
```
$ build/sbt "catalyst/testOnly *AnsiCastSuiteWithAnsiModeOn *ExpressionEncoderSuite -- -z parse -z nested"
...
[info] All tests passed.
```

### How was this patch tested?

Pass the CIs on `branch-3.1`. Currently, it's broken.

Closes #31775 from dongjoon-hyun/SPARK-34660.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
@dongjoon-hyun dongjoon-hyun deleted the SPARK-34660 branch March 8, 2021 07:42
@maropu
Copy link
Member

maropu commented Mar 8, 2021

late lgtm.

@cloud-fan
Copy link
Contributor

late LGTM

val activeConf = conf
new ParVector(ALL_TIMEZONES.toVector).foreach { zid =>
ALL_TIMEZONES.foreach { zid =>
def checkCastWithParseError(str: String): Unit = {
Copy link
Member

Choose a reason for hiding this comment

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

nit: It looks like we don't need to wrap SQLConf.withExistingConf now.

@viirya
Copy link
Member

viirya commented Mar 8, 2021

late lgtm

@SparkQA
Copy link

SparkQA commented Mar 8, 2021

Test build #135857 has finished for PR 31775 at commit 6bfb870.

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

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Mar 8, 2021

Thank you, @maropu , @cloud-fan , @viirya .

BTW, @maropu . Could you make a follow-up if needed, please?

nit: It looks like we don't need to wrap SQLConf.withExistingConf now.

@maropu
Copy link
Member

maropu commented Mar 9, 2021

Yea, I'll do it later.

dongjoon-hyun pushed a commit that referenced this pull request Mar 9, 2021
…n CastSuite

### What changes were proposed in this pull request?

This PR intends to remove unnecessary `SQLConf.withExistingConf` in `CastSuite`; since we've remove `ParVector ` in #31775, we no longer need to copy SQL configs into each thread env.

### Why are the changes needed?

Clean up the code.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Run the existing tests.

Closes #31785 from maropu/UpdateCastSuite.

Authored-by: Takeshi Yamamuro <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
dongjoon-hyun pushed a commit that referenced this pull request Mar 12, 2021
…onf in CastSuite

### What changes were proposed in this pull request?

This PR intends to remove unnecessary `SQLConf.withExistingConf` in `CastSuite`; since we've remove `ParVector ` in #31775, we no longer need to copy SQL configs into each thread env.

This PR is a backport of #31785.

### Why are the changes needed?

Clean up the code.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Run the existing tests.

Closes #31813 from maropu/SPARK-33498-BRANCH3.1.

Authored-by: Takeshi Yamamuro <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
flyrain pushed a commit to flyrain/spark that referenced this pull request Sep 21, 2021
… which is not thread-safe

This PR aims to remove `ParVector` usage with `withExistingConf` in `CastSuite` in order to fix UT failures.
- This was added by SPARK-33498 .
- `master` branch doesn't use `ParVector`.

```scala
- new ParVector(ALL_TIMEZONES.toVector).foreach { zid =>
+ ALL_TIMEZONES.foreach { zid =>
```

`withExistingConf` is not thread-safe like the following. We should not use `ParVector` on it.
```scala
def withExistingConf[T](conf: SQLConf)(f: => T): T = {
  val old = existingConf.get()
  existingConf.set(conf)
  try {
    f
  } finally {
    if (old != null) {
      existingConf.set(old)
    } else {
      existingConf.remove()
    }
  }
}
```

**BEFORE**
```
$ build/sbt "catalyst/testOnly *AnsiCastSuiteWithAnsiModeOn *ExpressionEncoderSuite -- -z parse -z nested"
...
[info] *** 4 TESTS FAILED ***
[error] Failed: Total 8, Failed 4, Errors 0, Passed 4
[error] Failed tests:
[error] 	org.apache.spark.sql.catalyst.encoders.ExpressionEncoderSuite
```

**AFTER**
```
$ build/sbt "catalyst/testOnly *AnsiCastSuiteWithAnsiModeOn *ExpressionEncoderSuite -- -z parse -z nested"
...
[info] All tests passed.
```

Pass the CIs on `branch-3.1`. Currently, it's broken.

Closes apache#31775 from dongjoon-hyun/SPARK-34660.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
flyrain pushed a commit to flyrain/spark that referenced this pull request Sep 21, 2021
…onf in CastSuite

### What changes were proposed in this pull request?

This PR intends to remove unnecessary `SQLConf.withExistingConf` in `CastSuite`; since we've remove `ParVector ` in apache#31775, we no longer need to copy SQL configs into each thread env.

This PR is a backport of apache#31785.

### Why are the changes needed?

Clean up the code.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Run the existing tests.

Closes apache#31813 from maropu/SPARK-33498-BRANCH3.1.

Authored-by: Takeshi Yamamuro <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants