BuildOnViction / tomox-sdk

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

OHLCV getCacheByName fatal error: concurrent map writes #145

Closed thanhson1085 closed 4 years ago

thanhson1085 commented 4 years ago
fatal error: concurrent map writes

goroutine 721884 [running]:
runtime.throw(0xd47618, 0x15)
        /home/tomodex/.go/src/runtime/panic.go:1112 +0x72 fp=0xc00d69b0d0 sp=0xc00d69b0a0 pc=0x436572
runtime.mapassign_faststr(0xc37a20, 0xc00039de60, 0xc016ab9a80, 0x9, 0x0)
        /home/tomodex/.go/src/runtime/map_faststr.go:211 +0x3f7 fp=0xc00d69b138 sp=0xc00d69b0d0 pc=0x415527
github.com/tomochain/tomox-sdk/services.(*OHLCVService).getCachePairByName(0xc0003a0af0, 0xc016ab9a80, 0x9, 0x0, 0x0, 0x1)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/ohlcv.go:1312 +0x1dd fp=0xc00d69b1a8 sp=0xc00d69b138 pc=0xad5d5d
github.com/tomochain/tomox-sdk/services.(*OHLCVService).getLastPricePairAtTime(0xc0003a0af0, 0xc016ab9a80, 0x9, 0xbfb2e722e7419f2e, 0x33db9e29971b, 0x1660c20, 0x9, 0xc00f261912, 0x4)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/ohlcv.go:1253 +0xc8 fp=0xc00d69b2f0 sp=0xc00d69b1a8 pc=0xad4f68
github.com/tomochain/tomox-sdk/services.(*OHLCVService).getLastPriceCurrentByTime(0xc0003a0af0, 0xc013408070, 0x4, 0xbfb2e722e7419f2e, 0x33db9e29971b, 0x1660c20, 0x5eeb250b, 0xc00403b410, 0x4c71c6)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/ohlcv.go:1272 +0xb7 fp=0xc00d69b3b0 sp=0xc00d69b2f0 pc=0xad5637
github.com/tomochain/tomox-sdk/services.(*OHLCVService).GetLastPriceCurrentByTime(0xc0003a0af0, 0xc013408070, 0x4, 0xbfb2e722e7419f2e, 0x33db9e29971b, 0x1660c20, 0x0, 0x0, 0x0)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/ohlcv.go:1299 +0xc1 fp=0xc00d69b420 sp=0xc00d69b3b0 pc=0xad5af1
github.com/tomochain/tomox-sdk/services.(*AccountService).GetTokenBalanceProvidor(0xc0001a20e0, 0xaab3980b087437d1, 0x37adcd47ea11def3, 0xbb0a7b17, 0x0, 0x100000000000000, 0x0, 0x100000000203000, 0x0)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/account.go:250 +0x988 fp=0xc00d69b600 sp=0xc00d69b420 pc=0xaacc08
github.com/tomochain/tomox-sdk/services.(*AccountService).GetByAddress(0xc0001a20e0, 0xaab3980b087437d1, 0x37adcd47ea11def3, 0x37adcd47bb0a7b17, 0xc0bb0a7b17, 0x7f5d86ede7d0, 0x0)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/services/account.go:189 +0x1bc fp=0xc00d69b858 sp=0xc00d69b600 pc=0xaac05c
github.com/tomochain/tomox-sdk/endpoints.(*AccountEndpoint).handleGetAccount(0xc009517700, 0xebf560, 0xc0050840e0, 0xc001e32800)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/endpoints/accounts.go:103 +0xf3 fp=0xc00d69b910 sp=0xc00d69b858 pc=0xb34003
github.com/tomochain/tomox-sdk/endpoints.(*AccountEndpoint).handleGetAccount-fm(0xebf560, 0xc0050840e0, 0xc001e32800)
        /home/tomodex/go/src/github.com/tomochain/tomox-sdk/endpoints/accounts.go:93 +0x48 fp=0xc00d69b940 sp=0xc00d69b910 pc=0xb6a8a8
net/http.HandlerFunc.ServeHTTP(0xc0095177f0, 0xebf560, 0xc0050840e0, 0xc001e32800)
        /home/tomodex/.go/src/net/http/server.go:2012 +0x44 fp=0xc00d69b968 sp=0xc00d69b940 pc=0x6e2734
github.com/gorilla/mux.(*Router).ServeHTTP(0xc000354070, 0xebf560, 0xc0050840e0, 0xc001e32600)
        /home/tomodex/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x112 fp=0xc00d69bab0 sp=0xc00d69b968 pc=0x76bbf2
github.com/gorilla/handlers.(*cors).ServeHTTP(0xc0057bcbd0, 0xebf560, 0xc0050840e0, 0xc001e32600)
        /home/tomodex/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/cors.go:52 +0xffc fp=0xc00d69bbe8 sp=0xc00d69bab0 pc=0x76a5ec
net/http.serverHandler.ServeHTTP(0xc001370c40, 0xebf560, 0xc0050840e0, 0xc001e32600)
        /home/tomodex/.go/src/net/http/server.go:2807 +0xa3 fp=0xc00d69bc18 sp=0xc00d69bbe8 pc=0x6e5bc3
net/http.(*conn).serve(0xc0002d65a0, 0xec23a0, 0xc003620540)
        /home/tomodex/.go/src/net/http/server.go:1895 +0x86c fp=0xc00d69bfc8 sp=0xc00d69bc18 pc=0x6e153c
runtime.goexit()
        /home/tomodex/.go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00d69bfd0 sp=0xc00d69bfc8 pc=0x466211
created by net/http.(*Server).Serve
        /home/tomodex/.go/src/net/http/server.go:2933 +0x35c
thanhson1085 commented 4 years ago

Fixed https://github.com/tomochain/tomox-sdk/commit/f724dc7bf06cb782e6e6fd8286c7f745edb069d0