The connected boolean does not have any synchronization surrounding it, allowing a single client used in multiple go routines to race around connecting to Riak. If a user does not call Connect on a fresh Client, things can go horribly wrong. Instead use a special sentinel value in the conns channel (nil), that marks the Client as not being connected. This requires some juggling to ensure that the channel always has a nil value in it, but this only occurs when the client is unconnected, so getting a connection shouldn't be significantly impacted, and the test suite takes about the same amount of time either way. Also drain the created conns in Connect if a few were created before an error occurs. Generally speaking, this won't happen often. It just ensures a disconnected client only has the sentinel value in conns. Also, ensure calling Close and Connect don't race. Close can't be called simultaneously with other Close, as they will all try to drain the conns channel and block forever. However, they all obey the connected state, so calling it multiple times is not an issue. Make sure Close and Connect also don't race. Normally, this isn't an issue as Close will drain the connect channel as fast as Connect fills it. However, if Connect generates an error, then it will also try to drain the conns channel, ensuring a deadlock. So make sure both don't run at the same time. Having multiple Connect calls is fine, as Connect will race only to read the sentinel value. However Go ensures only one wins, and the others will simply get valid connections later, which will force them to quit early. Thus don't block multiple Connect calls, as connecting to Riak may take a significant time period where the code could be executing.
…clients. Avoid having multiple places creating new clients, instead just have the one place and have it instead be called as appropriate.
…ient.response to reset the client
- Fix a random build failure where Riak would still be setting up Riak Search when the search test is run, resulting in a failure. Instead wait for Riak to have started the search service. Also wait for the kv service to start, in case that ever becomes a problem in the future. - Instead of manually specifying the test dependencies, use the -t option to go get. - Build/test all packages in the repository. While they already should have been, this ensures it in the future.
…pdate the chunk_count in the root node