You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/07/07 23:01:19 UTC

[GitHub] [dubbo-go] CoolIceV opened a new pull request, #1958: Fix: fix rand.Seed() duplicate concurrent calls

CoolIceV opened a new pull request, #1958:
URL: https://github.com/apache/dubbo-go/pull/1958

   <!--  Thanks for sending a pull request!
   Read https://github.com/apache/dubbo-go/blob/master/CONTRIBUTING.md before commit pull request.
   -->
   
   **What this PR does**: 
   Move the rand.Seed() call to init()
   
   **Which issue(s) this PR fixes**: 
   Fixes #1957 
   
   **You should pay attention to items below to ensure your pr passes our ci test**
   We do not merge pr with ci tests failed
   
   - [ ] All ut passed (run 'go test ./...' in project root)
   - [ ] After go-fmt ed , run 'go fmt project' using goland.
   - [ ] Golangci-lint passed, run 'sudo golangci-lint run' in project root.
   - [ ] After import formatted, (using [imports-formatter](https://github.com/dubbogo/tools#5-how-to-get-imports-formatter) to run 'imports-formatter .' in project root, to format your import blocks, mentioned in [CONTRIBUTING.md](https://github.com/apache/dubbo-go/blob/master/CONTRIBUTING.md) above) 
   - [ ] Your new-created file needs to have [apache license](https://raw.githubusercontent.com/dubbogo/resources/master/tools/license/license.txt) at the top, like other existed file does.
   - [ ] All integration test passed. You can run integration test locally (with docker env). Clone our [dubbo-go-samples](https://github.com/apache/dubbo-go-samples) project and replace the go.mod to your dubbo-go, and run 'sudo sh start_integration_test.sh' at root of samples project root. (M1 Slice is not Support)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] CoolIceV commented on a diff in pull request #1958: Fix: fix rand.Seed() duplicate concurrent calls

Posted by GitBox <gi...@apache.org>.
CoolIceV commented on code in PR #1958:
URL: https://github.com/apache/dubbo-go/pull/1958#discussion_r916432282


##########
cluster/loadbalance/p2c/loadbalance.go:
##########
@@ -44,6 +44,7 @@ var (
 )
 
 func init() {
+	rand.Seed(randSeed())

Review Comment:
   Each init() is called only once in golang, and I think it is sufficient to ensure that the seed does not change after the program starts running, regardless of the number of times the rand.Seed() is called in the program.
   
   In addition, the imported third-party package may call rand.Seed() even if we only run it once



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks merged pull request #1958: Fix: fix rand.Seed() duplicate concurrent calls

Posted by GitBox <gi...@apache.org>.
AlexStocks merged PR #1958:
URL: https://github.com/apache/dubbo-go/pull/1958


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] sanxun0325 commented on a diff in pull request #1958: Fix: fix rand.Seed() duplicate concurrent calls

Posted by GitBox <gi...@apache.org>.
sanxun0325 commented on code in PR #1958:
URL: https://github.com/apache/dubbo-go/pull/1958#discussion_r916394407


##########
cluster/loadbalance/p2c/loadbalance.go:
##########
@@ -44,6 +44,7 @@ var (
 )
 
 func init() {
+	rand.Seed(randSeed())

Review Comment:
   rand.Seed  only need to initialize globally once



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei commented on a diff in pull request #1958: Fix: fix rand.Seed() duplicate concurrent calls

Posted by GitBox <gi...@apache.org>.
justxuewei commented on code in PR #1958:
URL: https://github.com/apache/dubbo-go/pull/1958#discussion_r916407564


##########
cluster/loadbalance/p2c/loadbalance.go:
##########
@@ -44,6 +44,7 @@ var (
 )
 
 func init() {
+	rand.Seed(randSeed())

Review Comment:
   Yes, I think there should be a `sync.Once` to initialize the seed globally. Did dubbo-go have it before?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei commented on a diff in pull request #1958: Fix: fix rand.Seed() duplicate concurrent calls

Posted by GitBox <gi...@apache.org>.
justxuewei commented on code in PR #1958:
URL: https://github.com/apache/dubbo-go/pull/1958#discussion_r916436280


##########
cluster/loadbalance/p2c/loadbalance.go:
##########
@@ -44,6 +44,7 @@ var (
 )
 
 func init() {
+	rand.Seed(randSeed())

Review Comment:
   Well, the number of initializations of the rand seed is not a very strict limit. This PR looks good for me. BTW, I am saying that initialize the rand seed **globally**, instead of initialize that in `init()` function of each package, but it doesn't matter now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter commented on pull request #1958: Fix: fix rand.Seed() duplicate concurrent calls

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #1958:
URL: https://github.com/apache/dubbo-go/pull/1958#issuecomment-1182655238

   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1958?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1958](https://codecov.io/gh/apache/dubbo-go/pull/1958?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ed6feb5) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/026711bc0921596c819daa81500dbcc20f73af95?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (026711b) will **decrease** coverage by `0.60%`.
   > The diff coverage is `27.27%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##              3.0    #1958      +/-   ##
   ==========================================
   - Coverage   44.96%   44.35%   -0.61%     
   ==========================================
     Files         287      283       -4     
     Lines       17135    17023     -112     
   ==========================================
   - Hits         7704     7551     -153     
   - Misses       8618     8668      +50     
   + Partials      813      804       -9     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1958?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [cluster/cluster/base/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2Jhc2UvY2x1c3Rlcl9pbnZva2VyLmdv) | `24.44% <ø> (ø)` | |
   | [cluster/cluster/broadcast/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2Jyb2FkY2FzdC9jbHVzdGVyX2ludm9rZXIuZ28=) | `80.00% <ø> (ø)` | |
   | [cluster/cluster/failback/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2ZhaWxiYWNrL2NsdXN0ZXJfaW52b2tlci5nbw==) | `75.82% <ø> (ø)` | |
   | [cluster/cluster/failover/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2ZhaWxvdmVyL2NsdXN0ZXJfaW52b2tlci5nbw==) | `66.66% <ø> (ø)` | |
   | [cluster/cluster/failsafe/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2ZhaWxzYWZlL2NsdXN0ZXJfaW52b2tlci5nbw==) | `81.81% <ø> (ø)` | |
   | [cluster/cluster/forking/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2ZvcmtpbmcvY2x1c3Rlcl9pbnZva2VyLmdv) | `58.33% <ø> (ø)` | |
   | [cluster/loadbalance/ringhash/ringhash.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yaW5naGFzaC9yaW5naGFzaC5nbw==) | `63.33% <ø> (ø)` | |
   | [cluster/router/tag/match.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdGFnL21hdGNoLmdv) | `90.69% <ø> (ø)` | |
   | [cluster/router/tag/router.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdGFnL3JvdXRlci5nbw==) | `59.64% <ø> (ø)` | |
   | [common/extension/proxy\_factory.go](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9wcm94eV9mYWN0b3J5Lmdv) | `0.00% <ø> (ø)` | |
   | ... and [131 more](https://codecov.io/gh/apache/dubbo-go/pull/1958/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1958?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1958?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [1abbc2e...ed6feb5](https://codecov.io/gh/apache/dubbo-go/pull/1958?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] sanxun0325 commented on a diff in pull request #1958: Fix: fix rand.Seed() duplicate concurrent calls

Posted by GitBox <gi...@apache.org>.
sanxun0325 commented on code in PR #1958:
URL: https://github.com/apache/dubbo-go/pull/1958#discussion_r916394407


##########
cluster/loadbalance/p2c/loadbalance.go:
##########
@@ -44,6 +44,7 @@ var (
 )
 
 func init() {
+	rand.Seed(randSeed())

Review Comment:
   rand.Seed  only need to initialize once



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei commented on a diff in pull request #1958: Fix: fix rand.Seed() duplicate concurrent calls

Posted by GitBox <gi...@apache.org>.
justxuewei commented on code in PR #1958:
URL: https://github.com/apache/dubbo-go/pull/1958#discussion_r916436280


##########
cluster/loadbalance/p2c/loadbalance.go:
##########
@@ -44,6 +44,7 @@ var (
 )
 
 func init() {
+	rand.Seed(randSeed())

Review Comment:
   Well, the number of initializations of the rand seed is not a very strict limit. This PR looks good for me.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org