BuildOnViction / tomox-sdk

SDK to build a Decentralized Exchange on TomoX protocol
MIT License
36 stars 18 forks source link

OHLCVService filterTick fatal error: concurrent map iteration and map write #148

Closed thanhson1085 closed 4 years ago

thanhson1085 commented 4 years ago

It made server restart 2 times

tomox-sdk-out__2020-06-21_00-00-00.log:16939:INFO 22:38:02 at server/server.go:49 in Start():Server port: 8080
tomox-sdk-out__2020-06-23_00-00-00.log:22698:INFO 22:43:28 at server/server.go:49 in Start():Server port: 8080
2020/06/22 22:05:34 Response with error
fatal error: concurrent map iteration and map write

goroutine 1733074 [running]:
runtime.throw(0xd6b4c8, 0x26)
        /home/tomodex/.go/src/runtime/panic.go:1112 +0x72 fp=0xc01600d278 sp=0xc01600d248 pc=0x436572
runtime.mapiternext(0xc01600d380)
        /home/tomodex/.go/src/runtime/map.go:853 +0x552 fp=0xc01600d2f8 sp=0xc01600d278 pc=0x411922
github.com/tomochain/tomox-sdk/services.(*OHLCVService).filterTick(0xc0001a25a0, 0xc016c88180, 0x5e, 0x5eefc670, 0x0, 0x9ea53501d794ed12, 0x1, 0xd25148)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/ohlcv.go:670 +0x12c fp=0xc01600d3f0 sp=0xc01600d2f8 pc=0xacaa1c
github.com/tomochain/tomox-sdk/services.(*OHLCVService).get24hTick(0xc0001a25a0, 0x0, 0x0, 0x40311b3801000000, 0xf0cfb21909224d9e, 0x9ea53501d794ed12, 0x0)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/ohlcv.go:720 +0x120 fp=0xc01600d500 sp=0xc01600d3f0 pc=0xacb350
github.com/tomochain/tomox-sdk/services.(*OHLCVService).getTokenPairData(0xc0001a25a0, 0xc00d7435d0, 0x9, 0xc00d7431c0, 0x4, 0x0, 0x0, 0x40311b3801000000, 0xf0cfb21909224d9e, 0x9ea53501d794ed12, ...)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/ohlcv.go:1069 +0x77 fp=0xc01600d6b0 sp=0xc01600d500 pc=0xad2bf7
github.com/tomochain/tomox-sdk/services.(*OHLCVService).GetTokenPairData(0xc0001a25a0, 0x0, 0x0, 0x40311b3801000000, 0xf0cfb21909224d9e, 0x9ea53501d794ed12, 0x0)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/ohlcv.go:1118 +0x17f fp=0xc01600d748 sp=0xc01600d6b0 pc=0xad361f
github.com/tomochain/tomox-sdk/services.(*PairService).GetAllTokenPairDataByCoinbase(0xc00022c070, 0x8dc8dac29eb38bde, 0x893acc182eb6873f, 0x893acc1884bc98e2, 0xc084bc98e2, 0x7fab9babe7d0, 0x0, 0x30, 0xcbf120)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/pair.go:213 +0x161 fp=0xc01600d858 sp=0xc01600d748 pc=0xae0281
github.com/tomochain/tomox-sdk/endpoints.(*MarketsEndpoint).HandleGetAllMarketStats(0xc000ec9440, 0xec18a0, 0xc00e093c00, 0xc003a56100)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/endpoints/markets.go:39 +0x98 fp=0xc01600d910 sp=0xc01600d858 pc=0xb4e608
github.com/tomochain/tomox-sdk/endpoints.(*MarketsEndpoint).HandleGetAllMarketStats-fm(0xec18a0, 0xc00e093c00, 0xc003a56100)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/endpoints/markets.go:36 +0x48 fp=0xc01600d940 sp=0xc01600d910 pc=0xb6d1e8
net/http.HandlerFunc.ServeHTTP(0xc000ec6c90, 0xec18a0, 0xc00e093c00, 0xc003a56100)
        /home/tomodex/.go/src/net/http/server.go:2012 +0x44 fp=0xc01600d968 sp=0xc01600d940 pc=0x6e2734
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0001cc070, 0xec18a0, 0xc00e093c00, 0xc008795f00)
        /home/tomodex/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x112 fp=0xc01600dab0 sp=0xc01600d968 pc=0x76bbf2
github.com/gorilla/handlers.(*cors).ServeHTTP(0xc0104b9dd0, 0xec18a0, 0xc00e093c00, 0xc008795f00)
        /home/tomodex/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/cors.go:52 +0xffc fp=0xc01600dbe8 sp=0xc01600dab0 pc=0x76a5ec
net/http.serverHandler.ServeHTTP(0xc001dea0e0, 0xec18a0, 0xc00e093c00, 0xc008795f00)
        /home/tomodex/.go/src/net/http/server.go:2807 +0xa3 fp=0xc01600dc18 sp=0xc01600dbe8 pc=0x6e5bc3
net/http.(*conn).serve(0xc00013b720, 0xec46e0, 0xc01838eb00)
        /home/tomodex/.go/src/net/http/server.go:1895 +0x86c fp=0xc01600dfc8 sp=0xc01600dc18 pc=0x6e153c
runtime.goexit()
        /home/tomodex/.go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc01600dfd0 sp=0xc01600dfc8 pc=0x466211
created by net/http.(*Server).Serve
        /home/tomodex/.go/src/net/http/server.go:2933 +0x35c