Skip to content

Conversation

@peterbroadhurst
Copy link
Contributor

For newly created environments, this PR adds a 16 character unique suffix to the ethconnect subscription names it creates, using the instance path from the config at the time the sub is created. This means that if the contract instance changes in the future, we will re-subscribe to the new contract.

Note I also saw this issue in a test run on my machine, and added a change to read this config once on HTTP server startup.

fatal error: concurrent map read and map write

goroutine 150 [running]:
runtime.throw(0x496ca08, 0x21)
        /usr/local/Cellar/go/1.16.4/libexec/src/runtime/panic.go:1117 +0x72 fp=0xc000121c48 sp=0xc000121c18 pc=0x403aa12
runtime.mapaccess2_faststr(0x488eba0, 0xc0005eb3b0, 0xc0000301f8, 0x3, 0x0, 0x0)
        /usr/local/Cellar/go/1.16.4/libexec/src/runtime/map_faststr.go:116 +0x4a5 fp=0xc000121cb8 sp=0xc000121c48 pc=0x4016fe5
github.com/spf13/viper.(*Viper).searchMap(0xc0002dad80, 0xc0005eb3b0, 0xc0003bc300, 0x2, 0x2, 0x0, 0x0)
        /Users/peterbroadhurst/dev/go/pkg/mod/github.com/spf13/viper@v1.8.1/viper.go:568 +0x5f fp=0xc000121d00 sp=0xc000121cb8 pc=0x445665f
github.com/spf13/viper.(*Viper).find(0xc0002dad80, 0xc0000301f8, 0x13, 0x1, 0xc000121e70, 0x2)
        /Users/peterbroadhurst/dev/go/pkg/mod/github.com/spf13/viper@v1.8.1/viper.go:1218 +0x40e fp=0xc000121e10 sp=0xc000121d00 pc=0x445842e
github.com/spf13/viper.(*Viper).Get(0xc0002dad80, 0x4960281, 0x13, 0x43e8965, 0x4e65370)
        /Users/peterbroadhurst/dev/go/pkg/mod/github.com/spf13/viper@v1.8.1/viper.go:798 +0x85 fp=0xc000121ea8 sp=0xc000121e10 pc=0x4457425
github.com/spf13/viper.(*Viper).GetString(0xc0002dad80, 0x4960281, 0x13, 0x4960281, 0x13)
        /Users/peterbroadhurst/dev/go/pkg/mod/github.com/spf13/viper@v1.8.1/viper.go:865 +0x3f fp=0xc000121ee8 sp=0xc000121ea8 pc=0x4457c3f
github.com/spf13/viper.GetString(...)
        /Users/peterbroadhurst/dev/go/pkg/mod/github.com/spf13/viper@v1.8.1/viper.go:862
github.com/hyperledger/firefly/internal/config.(*configPrefix).GetDuration(0x4e318f0, 0x4960281, 0x13, 0x2c)
        /Users/peterbroadhurst/dev/photic/firefly/internal/config/config.go:551 +0x69 fp=0xc000121f20 sp=0xc000121ee8 pc=0x445cdc9
github.com/hyperledger/firefly/internal/config.GetDuration(...)
        /Users/peterbroadhurst/dev/photic/firefly/internal/config/config.go:548
github.com/hyperledger/firefly/internal/apiserver.(*httpServer).serveHTTP.func1(0x4a4c2d8, 0xc000021ac0, 0xc0001c4fc0, 0xc00061c660)
        /Users/peterbroadhurst/dev/photic/firefly/internal/apiserver/http_server.go:175 +0x179 fp=0xc000121fc0 sp=0xc000121f20 pc=0x46c4279
runtime.goexit()
        /usr/local/Cellar/go/1.16.4/libexec/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc000121fc8 sp=0xc000121fc0 pc=0x4073f21
created by github.com/hyperledger/firefly/internal/apiserver.(*httpServer).serveHTTP
        /Users/peterbroadhurst/dev/photic/firefly/internal/apiserver/http_server.go:171 +0x98

Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2021

Codecov Report

Merging #256 (418c678) into main (ed01763) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #256      +/-   ##
==========================================
- Coverage   99.55%   99.53%   -0.03%     
==========================================
  Files         217      217              
  Lines       12181    12185       +4     
==========================================
+ Hits        12127    12128       +1     
- Misses         40       42       +2     
- Partials       14       15       +1     
Impacted Files Coverage Δ
internal/apiserver/http_server.go 100.00% <100.00%> (ø)
internal/blockchain/ethereum/ethereum.go 100.00% <100.00%> (ø)
internal/config/config.go 100.00% <100.00%> (ø)
internal/blockchain/fabric/fabric.go 88.62% <0.00%> (-1.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed01763...418c678. Read the comment docs.

Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Copy link
Contributor

@nguyer nguyer left a comment

Choose a reason for hiding this comment

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

Looks like there was a slight drop in coverage. Other than that, looks good.


// GetKnownKeys gets the known keys
func GetKnownKeys() []string {
var keys []string
Copy link

Choose a reason for hiding this comment

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

If this tends to be called a lot, one improvement to consider is to create keys to be the length of knownKeys instead of appending.

keys := make([]string, len(knownKeys))
...
idx := 0
for k := range knownKeys {
    keys[idx++] = k
}

@peterbroadhurst
Copy link
Contributor Author

The drop in coverage is in internal/blockchain/fabric/fabric.go

Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
@peterbroadhurst peterbroadhurst merged commit 80f6839 into hyperledger:main Oct 15, 2021
@peterbroadhurst peterbroadhurst deleted the re-sub branch October 15, 2021 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants