influxdb/write
Jeff Wendling 9da6fb3410 fix(write): fix close logic to avoid race from read error
In the case that there is a read error, we would close the lines
channel before sending the error into the read error channel. closing
lines then allows the write goroutine to possibly send in a nil error
before read is able to, causing the main function driving both to
return a nil error. Additionally, it is possible for both reads and
writes to race sending errors into their channels, and the main
goroutine will only read from one, causing the other goroutine to leak.

To fix this, we close lines only after we have sent an error into
the channel, we ensure we read from both errors to make sure that
both have exited, and we unify the channels and add a buffer of size
two to the channel. It is possible for write to exit leaving read blocked
forever, but write only exits with a nil error when read has exited, so
this only happens during an actual write error, just like before.

Channels are hard.
2018-12-29 15:30:38 -07:00
..
batcher.go fix(write): fix close logic to avoid race from read error 2018-12-29 15:30:38 -07:00
batcher_test.go fix(write): fix close logic to avoid race from read error 2018-12-29 15:30:38 -07:00