Skip to content

Conversation

@daugraph
Copy link

@daugraph daugraph commented Sep 10, 2021

What changes were proposed in this pull request?

Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1

class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)

output:

false

Snippet 2

class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)

output:

true

Why are the changes needed?

we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Does this PR introduce any user-facing change?

No

How was this patch tested?

No

@github-actions github-actions bot added the CORE label Sep 10, 2021
@mridulm
Copy link
Contributor

mridulm commented Sep 10, 2021

Ok to test

@SparkQA
Copy link

SparkQA commented Sep 10, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47657/

@SparkQA
Copy link

SparkQA commented Sep 10, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47657/

Copy link
Contributor

@mridulm mridulm left a comment

Choose a reason for hiding this comment

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

The fix looks good to me.
Can you add a test to surface the issue (without the fix) and verify it is addressed with this fix.

@SparkQA
Copy link

SparkQA commented Sep 10, 2021

Test build #143153 has finished for PR 33957 at commit ea52165.

  • 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 for @mridulm 's comment. It would be great if we can have a small test case.

@dongjoon-hyun
Copy link
Member

BTW, thank you for making a PR, @daugraph .

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

same comments as @dongjoon-hyun and @mridulm. Looks good otherwise.

@daugraph
Copy link
Author

daugraph commented Oct 3, 2021

I have no idea about how to add the test case, plz give me some advice, thanks

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

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

I wonder if you can simply add a test alongside other broadcast tests, that sets the flag here to true in conf, then instantiates this object, then checks whether the flag is true? it would only work if this fix works

@mridulm
Copy link
Contributor

mridulm commented Oct 3, 2021

You could create a broadcast variable and check if checksums array is non-null.
Either via reflection or add a private[broadcast] def getChecksums = checksums - and validate the array has results.

@srowen
Copy link
Member

srowen commented Oct 7, 2021

If we're stuck on adding a trivial test here, I'm inclined to just proceed - it's a clean fix and existing tests pass

@srowen
Copy link
Member

srowen commented Oct 7, 2021

Jenkins test this please

@SparkQA
Copy link

SparkQA commented Oct 7, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48468/

@SparkQA
Copy link

SparkQA commented Oct 7, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48468/

@SparkQA
Copy link

SparkQA commented Oct 7, 2021

Test build #144000 has finished for PR 33957 at commit ea52165.

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

@HyukjinKwon
Copy link
Member

Yeah, I am okie too.

@srowen srowen closed this in 65f6a7c Oct 8, 2021
srowen pushed a commit that referenced this pull request Oct 8, 2021
…ad incorrect behavior

### What changes were proposed in this pull request?
Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1
```scala
class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
false
```
 Snippet 2
```scala
class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
true
```

### Why are the changes needed?
we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

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

### How was this patch tested?
No

Closes #33957 from daugraph/branch0.

Authored-by: daugraph <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
(cherry picked from commit 65f6a7c)
Signed-off-by: Sean Owen <[email protected]>
srowen pushed a commit that referenced this pull request Oct 8, 2021
…ad incorrect behavior

### What changes were proposed in this pull request?
Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1
```scala
class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
false
```
 Snippet 2
```scala
class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
true
```

### Why are the changes needed?
we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

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

### How was this patch tested?
No

Closes #33957 from daugraph/branch0.

Authored-by: daugraph <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
(cherry picked from commit 65f6a7c)
Signed-off-by: Sean Owen <[email protected]>
srowen pushed a commit that referenced this pull request Oct 8, 2021
…ad incorrect behavior

### What changes were proposed in this pull request?
Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1
```scala
class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
false
```
 Snippet 2
```scala
class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
true
```

### Why are the changes needed?
we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

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

### How was this patch tested?
No

Closes #33957 from daugraph/branch0.

Authored-by: daugraph <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
(cherry picked from commit 65f6a7c)
Signed-off-by: Sean Owen <[email protected]>
@srowen
Copy link
Member

srowen commented Oct 8, 2021

Merged to master/3.2/3.1/3.0

sunchao pushed a commit to sunchao/spark that referenced this pull request Dec 8, 2021
…ad incorrect behavior

### What changes were proposed in this pull request?
Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1
```scala
class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
false
```
 Snippet 2
```scala
class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
true
```

### Why are the changes needed?
we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

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

### How was this patch tested?
No

Closes apache#33957 from daugraph/branch0.

Authored-by: daugraph <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
(cherry picked from commit 65f6a7c)
Signed-off-by: Sean Owen <[email protected]>
fishcus pushed a commit to fishcus/spark that referenced this pull request Jan 12, 2022
…ad incorrect behavior

### What changes were proposed in this pull request?
Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1
```scala
class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
false
```
 Snippet 2
```scala
class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
true
```

### Why are the changes needed?
we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

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

### How was this patch tested?
No

Closes apache#33957 from daugraph/branch0.

Authored-by: daugraph <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
(cherry picked from commit 65f6a7c)
Signed-off-by: Sean Owen <[email protected]>
catalinii pushed a commit to lyft/spark that referenced this pull request Feb 22, 2022
…ad incorrect behavior

### What changes were proposed in this pull request?
Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1
```scala
class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
false
```
 Snippet 2
```scala
class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
true
```

### Why are the changes needed?
we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

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

### How was this patch tested?
No

Closes apache#33957 from daugraph/branch0.

Authored-by: daugraph <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
(cherry picked from commit 65f6a7c)
Signed-off-by: Sean Owen <[email protected]>
catalinii pushed a commit to lyft/spark that referenced this pull request Mar 4, 2022
…ad incorrect behavior

### What changes were proposed in this pull request?
Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1
```scala
class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
false
```
 Snippet 2
```scala
class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
true
```

### Why are the changes needed?
we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

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

### How was this patch tested?
No

Closes apache#33957 from daugraph/branch0.

Authored-by: daugraph <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
(cherry picked from commit 65f6a7c)
Signed-off-by: Sean Owen <[email protected]>
wangyum pushed a commit that referenced this pull request May 26, 2023
…ad incorrect behavior

Incorrect order of variable initialization may lead to incorrect behavior, related code: TorrentBroadcast.scala , TorrentBroadCast will get wrong checksumEnabled value after initialization, this may not be what we need, we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

Supplement:
Snippet 1
```scala
class Broadcast {
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
  var checksumEnabled = false
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
false
```
 Snippet 2
```scala
class Broadcast {
  var checksumEnabled = false
  def setConf(): Unit = {
    checksumEnabled = true
  }
  setConf()
}
println(new Broadcast().checksumEnabled)
```
output:
```scala
true
```

we can move L94 front of setConf(SparkEnv.get.conf) to avoid this.

No

No

Closes #33957 from daugraph/branch0.

Authored-by: daugraph <[email protected]>
Signed-off-by: Sean Owen <[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