bitcoin-sv / merchantapi-reference

Merchant API reference implementation
Other
23 stars 17 forks source link

WARNING: DATA RACE when trying to 3 use 3 bitcoin nodes #3

Closed ghost closed 4 years ago

ghost commented 4 years ago

Problem:

WARNING: DATA RACE when trying to 3 use 3 bitcoin nodes.

Expected result:

No DATA RACE and the user is able to submit their transaction without error.

Actual Result:

Unable to submit sample transaction without the result giving a failure and a "Mixed results" string.

POST /mapi/tx

Content-type: application/json Request body:

 {
  "rawTx": "0100000001df7ffab6c59dfc18764c42ffdc771124781267cc706377431d050040a88d4125030000006a473044022017c3c38d7be9b190f792714de48b0f852b6bcde4df1dc603bff94b02f32a8deb02200517d8342b8752bff0ea6130924dc2602ae18f6c0526f731da5d3e6a2b02dcaa412102119ebe4639964590bcf358539740f8ea4b6546b8416cbbbf6de12fafd3a13d1affffffff01000000000000000014006a026d020e706f737420746f206d656d6f212000000000"
} 

Config file:

$ cat settings.conf
# The server can listen on http or https or both.
# Depending on these settings, the server
# will bind to a specific interface or all interfaces
#   httpAddress=:9004
#   httpsAddress=192.168.1.2:8334

# For https connections, you can also provide certificates
#   certFile=./fullchain.pem
#   keyFile=./privkey.pem
httpAddress=:8065
httpsAddress= # Don't start https

# The JWT key is used for all tokens.  To revoke all tokens, change this key.
# To generate a new jwtKey, run the following script:
#   node -e "console.log(require('crypto').randomBytes(32).toString('hex'));"
jwtKey=

# GetFeeQuote returns a feeQuote with an expiry time, this value will
# set the value of that expiry time (in minutes)
quoteExpiryMinutes=10

bitcoin_count=3
bitcoin_1_host=localhost
bitcoin_1_port=8332
bitcoin_1_username=secretuser
bitcoin_1_password=password
bitcoin_2_host=hostname2
bitcoin_2_port=8332
bitcoin_2_username=secretuser
bitcoin_2_password=password
bitcoin_3_host=hostname3
bitcoin_3_port=8332
bitcoin_3_username=secretuser
bitcoin_3_password=password

Logs:

May 30 01:35:40 ip-172-31-26-17 go[1344]: 2020/05/30 01:35:40 INFO: HTTP server listening on :8065
May 30 01:35:58 ip-172-31-26-17 go[1344]: ==================
May 30 01:35:58 ip-172-31-26-17 go[1344]: WARNING: DATA RACE
May 30 01:35:58 ip-172-31-26-17 go[1344]: Read at 0x00c0002f47e0 by goroutine 37:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:82 +0x301
May 30 01:35:58 ip-172-31-26-17 go[1344]: Previous write at 0x00c0002f47e0 by goroutine 36:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:83 +0x24f
May 30 01:35:58 ip-172-31-26-17 go[1344]: Goroutine 37 (running) created at:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:62 +0x1c6
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.SubmitTransaction()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/SubmitTransaction.go:77 +0x6e5
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x4ca
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.AuthMiddleware.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/AuthMiddleware.go:19 +0x497
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.CORSMethodMiddleware.func1.1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/middleware.go:51 +0x13f
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.(*Router).ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/mux.go:212 +0x13e
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.serverHandler.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2807 +0xce
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.(*conn).serve()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:1895 +0x837
May 30 01:35:58 ip-172-31-26-17 go[1344]: Goroutine 36 (finished) created at:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:62 +0x1c6
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.SubmitTransaction()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/SubmitTransaction.go:77 +0x6e5
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x4ca
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.AuthMiddleware.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/AuthMiddleware.go:19 +0x497
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.CORSMethodMiddleware.func1.1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/middleware.go:51 +0x13f
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.(*Router).ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/mux.go:212 +0x13e
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.serverHandler.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2807 +0xce
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.(*conn).serve()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:1895 +0x837
May 30 01:35:58 ip-172-31-26-17 go[1344]: ==================
May 30 01:35:58 ip-172-31-26-17 go[1344]: WARNING: DATA RACE
May 30 01:35:58 ip-172-31-26-17 go[1344]: Read at 0x00c0002f4a20 by goroutine 37:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.contains()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:38 +0x67
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:82 +0x34b
May 30 01:35:58 ip-172-31-26-17 go[1344]: Previous write at 0x00c0002f4a20 by goroutine 36:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:83 +0x202
May 30 01:35:58 ip-172-31-26-17 go[1344]: Goroutine 37 (running) created at:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:62 +0x1c6
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.SubmitTransaction()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/SubmitTransaction.go:77 +0x6e5
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x4ca
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.AuthMiddleware.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/AuthMiddleware.go:19 +0x497
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.CORSMethodMiddleware.func1.1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/middleware.go:51 +0x13f
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.(*Router).ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/mux.go:212 +0x13e
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.serverHandler.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2807 +0xce
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.(*conn).serve()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:1895 +0x837
May 30 01:35:58 ip-172-31-26-17 go[1344]: Goroutine 36 (finished) created at:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:62 +0x1c6
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.SubmitTransaction()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/SubmitTransaction.go:77 +0x6e5
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x4ca
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.AuthMiddleware.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/AuthMiddleware.go:19 +0x497
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.CORSMethodMiddleware.func1.1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/middleware.go:51 +0x13f
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.(*Router).ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/mux.go:212 +0x13e
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.serverHandler.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2807 +0xce
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.(*conn).serve()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:1895 +0x837
May 30 01:35:58 ip-172-31-26-17 go[1344]: ==================
May 30 01:35:58 ip-172-31-26-17 go[1344]: WARNING: DATA RACE
May 30 01:35:58 ip-172-31-26-17 go[1344]: Read at 0x00c0002f4a20 by goroutine 35:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.contains()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:38 +0x67
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:82 +0x34b
May 30 01:35:58 ip-172-31-26-17 go[1344]: Previous write at 0x00c0002f4a20 by goroutine 36:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:83 +0x202
May 30 01:35:58 ip-172-31-26-17 go[1344]: Goroutine 35 (running) created at:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:62 +0x1c6
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.SubmitTransaction()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/SubmitTransaction.go:77 +0x6e5
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x4ca
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.AuthMiddleware.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/AuthMiddleware.go:19 +0x497
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.CORSMethodMiddleware.func1.1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/middleware.go:51 +0x13f
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.(*Router).ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/mux.go:212 +0x13e
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.serverHandler.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2807 +0xce
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.(*conn).serve()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:1895 +0x837
May 30 01:35:58 ip-172-31-26-17 go[1344]: Goroutine 36 (finished) created at:
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/multiplexer.(*MPWrapper).Invoke()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/multiplexer/mp.go:62 +0x1c6
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.SubmitTransaction()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/SubmitTransaction.go:77 +0x6e5
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x4ca
May 30 01:35:58 ip-172-31-26-17 go[1344]:   merchant_api/handler.AuthMiddleware.func1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /home/ubuntu/merchantapi/handler/AuthMiddleware.go:19 +0x497
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.CORSMethodMiddleware.func1.1()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/middleware.go:51 +0x13f
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.HandlerFunc.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2012 +0x51
May 30 01:35:58 ip-172-31-26-17 go[1344]:   github.com/gorilla/mux.(*Router).ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /root/go/pkg/mod/github.com/gorilla/mux@v1.7.3/mux.go:212 +0x13e
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.serverHandler.ServeHTTP()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:2807 +0xce
May 30 01:35:58 ip-172-31-26-17 go[1344]:   net/http.(*conn).serve()
May 30 01:35:58 ip-172-31-26-17 go[1344]:       /usr/lib/go-1.14/src/net/http/server.go:1895 +0x837
May 30 01:35:58 ip-172-31-26-17 go[1344]: ==================
May 30 01:35:58 ip-172-31-26-17 go[1344]: 2020/05/30 01:35:58 ERROR http://localhost:8332: Transaction already in the mempool